Have you annotated your JUnit test class one way or another to tell it to load the application context that it needs to wire the beans that you plan to use for testing. I have a feeling that your job bean is probably null at this point.
Above is the xml mapping in my project.
Here I want object of cListDAO using getBean() method.
To achieve this what I need to give for ClassPathXmlApplicationContext(“????”)
So since the entry point of this web application is through servlet API context initialized, the web application context is good enough since it is importing the other contexts that you may require.
Code:
public void testRunScheduledJob() {
AbstractApplicationContext context = new
ClassPathXmlApplicationContext("Integration-webapp.xml);
.
.
}
That should find it that way, then you can use the getBean methods as i showed you before.
------
If you are satisfied with the responses, add to the user's rep!
but "Integration-webapp.xml" is also not in classpath
it is in WEB-INF folder. I tried but file not found exception is comming. I belive loading is happening using web.xml.
Code:
WEB-INF/Integration-webapp.xml
Please help.
well the only problem here is a file lookup.
create another context under say src/test/resources
for unit tests which does what integration-webapp does then. This is usually the preferred way to do 'unit testing' and not 'integration testing' where you use another datasource (in memory database, etc).
------
If you are satisfied with the responses, add to the user's rep!
Bookmarks