I'm doing some integration tests with JUnit. I have an xml file where I declare some template entities which I want to inject. On every test, I need a fresh application context, that is no test should depend/couple with other tests, so on setUp() I need to 're-initialize' these entities on their default starting values.
I can achieve it through reloading, but this way I can't use @Autowired annotations.
@Before
public void setUp(){
ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:entityTemplates-Context.xml");
homeA = (Home)ctx.getBean("homeA");
}
Is there a way to do this and still use @Autowired for these entities?