I have following test class
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"/services-test-config.xml"})
public class MySericeTest {
@Autowired
MyService service;
...
}
Is it possible to access services-test-config.xml programmatically in one of such methods? Like:
ApplicationContext ctx = somehowGetContext();
Since the tests will be instantiated like a Spring bean too, you just need to implement the ApplicationContextAware interface:
For non xml needs, you can also do this: