I am using JUnit for unit testin for web services(Springs).

@RunWith(SpringJUnit4ClassRunner.class) 
@ContextConfiguration({"classpath:WSexample/config/service/WSexample-service.xml‌"}) 

and the test file is located in WSexample/test/find/controller location

I am using above code to load an xml file. it is throwing Failed to load Application Context error.

java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.j‌​ava:308) at org.springframework.test.context.support.DependencyInjectionTestExecutionListene‌​r.injectDependencies(DependencyInjectionTestExecutionListener.java:109) at org.springframework.test.context.support.DependencyInjectionTestExecutionListene‌​r.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestCont‌​extManager.java:321)

Can anyone help me out of this.

Thanks in advance.

1 Answers

0
John B On

You probably need to use the SpringJunit4ClassRunner and ContextConfiguration to load your context file.

Check out this post.

@RunWith(SpringJUnit4ClassRunner.class) 
@ContextConfiguration(locations={"classpath:myContext.xml"})