I have a unit test that is run with SpringJUnit4ClassRunner as follows:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:aConfig.xml")
public class TestService
{
@Resource
EmbeddedMysqlDatabase mysqlDB;
...
}
I have an embedded database that used in the unit tests that I would like to shutdown after all test have been run. I know embedding a database in a unit test is not usual/good practice but in this particular case this is super useful.
@AfterClass is not an option because it has to be static and my database instance is injected by spring. Static members cannot be injected.
How can i do that through a listener or any other means?
Thx.