Hi,
I'm using spring 3.1.2 and using maven 3.0.4 from the command line and from Eclipse's m2e plugin. I have some tests that will pass if the test is run singly, as in "mvn clean test -Dtest=com.company.neo.spring.view.NeoXsltViewResol verTest -e" However, when run alongside all the other unit tests, as in "mvn clean install -e" then this test will be in error.
In the particular case of NeoXsltViewResolverTest it is in error because the context is org.springframework.context.support.GenericApplica tionContext but the NeoXsltView gets the context and casts it to NeoXmlWebApplicationContext (extends from XmlWebApplicationContext)
XsltView extends org.springframework.context.support.ApplicationObj ectSupport, which means its setApplicationContext is final... Thus NeoXsltView cannot override ApplicationContextAware's setApplicationContext method, though it can implement ApplicationContextAware.Code:java.lang.ClassCastException: org.springframework.context.support.GenericApplicationContext cannot be cast to com.company.neo.spring.context.NeoXmlWebApplicationContext at com.company.neo.spring.view.NeoXsltView.getStylesheetSource(NeoXsltView.java:69) at org.springframework.web.servlet.view.xslt.XsltView.loadTemplates(XsltView.java:417) at org.springframework.web.servlet.view.xslt.XsltView.initApplicationContext(XsltView.java:181) at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119) at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
This isn't the only test that fails. Another test is harder to diagnose, but when it runs singly it scans certain files, and when run in the test suite it seems to scan extra files. I assume it must be the context has held over from the test that was run just prior, which had probably scanned some other file in its @ContextConfiguration then added some data to an @Autowired bean
Am I operating under false assumptions or is my context not getting cleared out for each unit test?


Reply With Quote
