It is explained here how combining java & xml configuration is done. It works. Test Context framework has java config support since 3.1.0.M2 :
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
public class LangDetectorTest extends AbstractTestNGSpringContextTests {
@Configuration
static class ContextConfiguration {
@Bean
public LangDetector langDetector() throws SystemException {
LangDetector orderService = new LangDetector();
return orderService;
}
}
}
Though I can’t figure out how to have java config as the main configuration and load something like util:properties and stuff from XML configuration.
I’d need to do somwthing like this:
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
@ImportResource("classpath:context/LangDetectorTest-test.xml")
public class LangDetectorTest extends AbstractTestNGSpringContextTests {
@Configuration
static class ContextConfiguration {
@Bean
public LangDetector langDetector() throws SystemException {
LangDetector orderService = new LangDetector();
return orderService;
}
}
}
Otherwise java config support for Test Context framework is useless, considering that there are tons of things that can be done only via XML configuration.
Quoting from springsource blog post :