Skip to content

Commit

Permalink
tomcat server start fix for issue hazelcast#3458
Browse files Browse the repository at this point in the history
  • Loading branch information
serkanozal committed Sep 2, 2014
1 parent 59f9d53 commit 9d7fbc0
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions hazelcast-wm/src/test/java/com/hazelcast/wm/test/TomcatServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,37 @@ public class TomcatServer implements ServletContainer {
Tomcat tomcat;
String serverXml;
String sourceDir;
int port;
volatile boolean running;

public TomcatServer(int port, String sourceDir, String serverXml) throws Exception {
this.port = port;
this.serverXml = serverXml;
this.sourceDir = sourceDir;
buildTomcat(port,sourceDir,serverXml);
buildTomcat(sourceDir, serverXml);
}

@Override
public void stop() throws LifecycleException {
public void stop() throws Exception {
tomcat.stop();
tomcat.destroy();
running = false;
}

@Override
public void start() throws Exception {
tomcat.start();
buildTomcat(sourceDir, serverXml);
running = true;
}

@Override
public void restart() throws LifecycleException, InterruptedException {
int port = tomcat.getConnector().getLocalPort();
tomcat.stop();
running = false;
tomcat.destroy();
Thread.sleep(5000);
buildTomcat(port, sourceDir, serverXml);
public void restart() throws Exception {
stop();
Thread.sleep(5000);
running = true;
start();
}

public void buildTomcat(int port, String sourceDir, String serverXml) throws LifecycleException {
public void buildTomcat(String sourceDir, String serverXml) throws LifecycleException {
tomcat = new Tomcat();
File baseDir = new File(System.getProperty("java.io.tmpdir"));
tomcat.setPort(port);
Expand Down

0 comments on commit 9d7fbc0

Please sign in to comment.