Tip for integration testing with Spring

If you subclass AbstractDependencyInjectionSpringContextTests (or any of its subclasses) then you don't need to lookup beans under test using

applicationContext.getBean("myBeanUnderTest")

.
By default these Spring classes use autowire by type so all you need to do is to add setter for required type.
E.g

public void setBeanUnderTest(MyBean bean) {
  this.beanUnderTest = bean;
}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.