Ahoj konference,

rozběhali jste někdo mock testování Stripes, pokud je projekt pod
Maven2? JUnit testy vždy spadnou po volání execute() ze třídy
MockRoundtrip na tom, že prostě nenajdou Action beany, navázané na
volané URL:

2008-02-18 13:32:31,609 WARN
[net.sourceforge.stripes.exception.DefaultExceptionHandler] -
Unhandled exception caught by the Stripes default exception handler.
net.sourceforge.stripes.exception.StripesServletException: Could not
locate an ActionBean that is bound to the URL [/action/test]. Commons
reasons for this include mis-matched URLs and forgetting to implement
ActionBean in your class. Registered ActionBeans are:
{/controller/DefaultView.action=class
net.sourceforge.stripes.controller.DefaultViewActionBean}

Takže to evidentně nenajde mé ActionBeany, využívané v testech.

Kód z test třídy (balíček cz.kyberie.test, JUnit 4.4), který
inicializuje Stripes servlet:

MockServletContext context = new MockServletContext("");
Map<String, String> filterParams = new HashMap<String, String>();

//filterParams.put("ActionResolver.UrlFilters",
"classes,test-classes"); //nyní zakomentováno, viz. dále
filterParams.put("ActionResolver.PackageFilters", "cz.kyberie.test.*");
context.addFilter(StripesFilter.class, "StripesFilter", filterParams);

// Add the Stripes Dispatcher
context.setServlet(DispatcherServlet.class, "StripesDispatcher", filterParams);

...

//testovaci metoda
    @Test
    public void save() throws Exception {

        MockRoundtrip trip = new MockRoundtrip(context, FirstActionBean.class);
        trip.setParameter("text", "ahoj");
        trip.execute();  // <<- TADY TO VYHODI VYJIMKU

    }

Na netu 
(http://www.nabble.com/Mock-container-test-failures-after-upgrading-to-Maven-Surefire-2.4(.1)-td15421263.html)
jsem našel pouze doporučení, aby se do UrlFilters přidaly rovnou
cesty, kam Maven builduje třídy:

filterParams.put("ActionResolver.UrlFilters", "classes,test-classes");

Avšak tato rada nepomohla.

Budu vděčný za nakopnutí.

Díky, Jirka Hradil

Odpovedet emailem