2010/3/9 carl ballantyne <carl.ballant...@cast-info.es>:
> Hi All,
>
> I ran into an issue with the StrutsSpringTestCase class when doing my unit
> tests. Basically the memory kept climbing until it crashed the machine.
>
> This class is actually loading the applicationContext for every test case
> that extends it. And because the applicationContext is static the instances
> of the spring beans loaded are not cleaned up by the garbage collector.
>
> What I ended up doing was overriding the method with the following in my
> base test class for Struts 2. The only difference being the check to see if
> applicationContext is null. This has the added benefit of speeding up the
> tests.
>
> protected void setupBeforeInitDispatcher() throws Exception {
>        // only load beans from spring once
>        if (applicationContext == null) {
>                GenericXmlContextLoader xmlContextLoader = new
> GenericXmlContextLoader();
>            applicationContext =
> xmlContextLoader.loadContext(getContextLocations());
>        }
>
>  servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
> applicationContext);
>    }
>
> Hope this helps anyone who runs into the same issue.
> Cheers,
> Carl.

Could you register a new issue with patch attached?
https://issues.apache.org/jira/browse/WW


Thanks in advance
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to