Skip to content

Commit

Permalink
Shutdown test container
Browse files Browse the repository at this point in the history
  • Loading branch information
haarli committed Nov 20, 2023
1 parent 7ef3022 commit 19fcb23
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.Servlet;
import javax.ws.rs.ProcessingException;
Expand All @@ -15,6 +17,7 @@
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.servlet.ServletContainer;
import org.glassfish.jersey.test.DeploymentContext;
import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory;
import org.glassfish.jersey.test.spi.TestContainer;
import org.glassfish.jersey.test.spi.TestContainerException;
import org.glassfish.jersey.test.spi.TestContainerFactory;
Expand All @@ -31,6 +34,8 @@
*/
public class MyTestContainerFactory implements TestContainerFactory {

private static final Logger LOGGER = Logger.getLogger(MyTestContainerFactory.class.getName());

public static final String REST_CONTEXT_PATH = "/rest";
public static final String STATIC_CONTEXT_PATH = "/static";
public static final String STATIC_CONTEXT_STORAGE = "src/test/resources/storage";
Expand Down Expand Up @@ -67,7 +72,13 @@ public void start() {

@Override
public void stop() {
this.server.shutdownNow();
if (this.server.isStarted()) {
LOGGER.log(Level.FINE, "Stopping GrizzlyTestContainer...");
this.server.shutdownNow();
} else {
LOGGER.log(Level.WARNING, "Ignoring stop request - GrizzlyTestContainer is already stopped.");
}

}
};

Expand Down

0 comments on commit 19fcb23

Please sign in to comment.