Seems weird to me. JUnit test runs fine from eclipse. But when I run from Ant command line, it shows error. Looks like its not loading / application context. Here is the base class of test class.
@ContextConfiguration(locations = { "classpath*:applicationContext.xml"})
public abstract class TransactionalTestCase extends StrutsSpringTransactionalTests {
@Before
public void onSetUp() throws Exception {
super.setUp();
}
@Override
protected void setupBeforeInitDispatcher() throws Exception {
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appContext);
}
When I try to print appContext
in this method, it prints
org.springframework.context.support.GenericApplicationContext@9320aa71: startup date xxxxxxx
But it prints null from ant build command line.
I compared the classpath of both eclipse and ant. Both are same. Includes same set of files and folders.
@ContextConfiguration
not taking effect when I run from ant build?
What else could be wrong?
StrutsSrpingTransactionalTests class
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
TransactionalTestExecutionListener.class,
DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class
})
@Transactional
public abstract class StrutsSpringTransactionalTests extends StrutsTestCase implements ApplicationContextAware {
protected ApplicationContext appContext;
@Override
public void setApplicationContext(ApplicationContext appContext) throws BeansException {
this.appContext = appContext;
}
}