Hi everyone,

I have a couple of JUnit tests that create a MockServletContext before each
test runs, with an @Before that creates the MockServletContext for me. I
notice when I run the entire suite of tests in this test class I get the
following error:

net.sourceforge.stripes.exception.StripesRuntimeException: Something is
trying to access the current Stripes configuration but the current request
was never routed through the StripesFilter! As a result the appropriate
Configuration object cannot be located. Please take a look at the exact URL
in your browser's address bar and ensure that any requests to that URL will
be filtered through the StripesFilter according to the filter mappings in
your web.xml.

I've googled a lot and found that some other people have had trouble with
this but couldn't find any solution other than this apparent bug fix:
http://www.stripesframework.org/jira/browse/STS-714

I don't understand the bug fix though, could someone explain to me what code
I need to write in my @After JUnit method to make this happen?

Here is my @Before method which runs before each unit test:

public void setUp() {
        context = new MockServletContext("test");
        // Add the Stripes Filter
        Map<String,String> filterParams = new HashMap<String,String>();
        filterParams.put("ActionResolver.Packages",
"au.com.secretsanta.web.action");
        context.addFilter(StripesFilter.class, "StripesFilter",
filterParams);
        context.addInitParameter("contextConfigLocation",
"/WEB-INF/applicationContext.xml test-jpaContext.xml
/WEB-INF/applicationContext-security.xml");

        //bind your context with an initializer
        ContextLoaderListener springContextListener = new
ContextLoaderListener();
        springContextListener.contextInitialized(new
ServletContextEvent(context));
        // Add the Stripes Dispatcher
        context.setServlet(DispatcherServlet.class, "StripesDispatcher",
null);
    }

Thanks,
Annie
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to