HttpService extends AbstractIdleService { @Override protected void shutDown() throws Exception { if (server == null) { LOGGER.error("Server is already stopped"); } else { LOGGER.debug("stopping {}", serviceName()); server.stop(); server = null; LOGGER.debug("stopped {}", serviceName()); } } @Inject  HttpService(
            @Named("application.http.port") int port,
            @Named("application.http.context.path") String contextPath,
            @Named("application.http.content.directory") @Nullable String contentDirectory,
            GuiceFilter guiceFilter);   }
@Test public void stopable() throws Exception { int port = 8080; Server server = createMockAndExpectNew(Server.class, port); HttpService httpService = new HttpService(port, "", null, guiceFilter); setInternalState(server, "_lock", new Object()); setInternalState(httpService, "server", server); expect(server.getConnectors()).andReturn(new Connector[]{}); setInternalState(server, "_state", 3); server.stop(); replay(server, Server.class); httpService.shutDown(); }
@Test public void notStopableAlreadyStarted() throws Exception { int port = 8080; Server server = createMock(Server.class, port); HttpService httpService = new HttpService(port, "", null, guiceFilter); replay(server, Server.class); httpService.shutDown(); }