I have a Maven project that starts a tomcat container for pre-integration-tests (jUnit Tests). Most of my tests require that the web-application under tests is restarted. So
I'm using follow method:
private static final String TOMCAT = "D:/test_tomcat";
@BeforeClass
public static void runTomcat() {
bootstrap = new Bootstrap();
bootstrap.setCatalinaHome(TOMCAT);
try {
bootstrap.start();
} catch (Exception e) {
e.printStackTrace();
fail("Не удалось запустить Tomcat");
}
}
@AfterClass
public static void stopTomcat() {
try {
bootstrap.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
But is method have a one problem - I need copy WAR file in 'webapps' directory every time have change source code. I thing what copy my class from classpath in web-inf and copy 'jar' from classpath in web-inf/lib.