InternalHttpServer { public void start() { Preconditions.checkState(webappDir != null, "Webapp dir can not be null"); initialize(); if (scanForApps) { registerApplications(); } else { logger.info("Not scanning for webapps"); } logger.info("Starting internal HTTP server"); try { server.start(); logger.info("Server started"); } catch (Exception e) { logger.warn("Caught exception during HTTP server start.", e); throw new InternalHttpServerException("Unable to start HTTP server", e); } } InternalHttpServer(); void initialize(); void start(); void stop(); @Override String toString(); Server getServer(); void setServer(Server server); File getWebappDir(); void setWebappDir(File webappDir); int getPort(); void setPort(int port); String getBindAddress(); void setBindAddress(String bindAddress); boolean getScanForApps(); void setScanForApps(boolean scanForApps); void addHandler(Context ctx); static Context createLogAppContext(); static Context createServletContext(Class<?> sltClz, String contextPath,
      String pathSpec, String name);  }
@Test public void testStartInvalidState() { boolean success = false; try { httpServer.start(); success = true; } catch (IllegalStateException e) { logger.info("Caught expected exception: {}", e.getMessage()); } Assert.assertFalse(success); }
@Test public void testStart() { boolean success = false; httpServer.setWebappDir(new File(getClass().getClassLoader() .getResource("test-webroot").getFile())); try { httpServer.start(); success = true; } catch (IllegalStateException e) { logger.error("Caught exception:", e); } Assert.assertTrue(success); try { Thread.sleep(5000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } success = false; try { httpServer.stop(); success = true; } catch (IllegalStateException e) { logger.error("Caught exception:", e); } Assert.assertTrue(success); }