Here's a Spock test that autowires the DAO objects.
@ContextConfiguration(locations = ['classpath:db2ResourceContext.xml']) public class Tester extends Specification implements ApplicationContextAware { @Shared private MyDAO dao = new MyDAO() def 'My Test'() { //use the dao confident the connection factory has been autowired } @Override public void setApplicationContext(ApplicationContext applicationContext) { applicationContext.autowireCapableBeanFactory.autowireBean(dao) } }
Post a Comment