AthenzJettyContainer { public static AthenzJettyContainer createJettyContainer() { int httpPort = ConfigProperties.getPortNumber(AthenzConsts.ATHENZ_PROP_HTTP_PORT, AthenzConsts.ATHENZ_HTTP_PORT_DEFAULT); int httpsPort = ConfigProperties.getPortNumber(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, AthenzConsts.ATHENZ_HTTPS_PORT_DEFAULT); int statusPort = ConfigProperties.getPortNumber(AthenzConsts.ATHENZ_PROP_STATUS_PORT, 0); String serverHostName = getServerHostName(); AthenzJettyContainer container = new AthenzJettyContainer(); container.setBanner("http: httpPort + " https port: " + httpsPort + " status port: " + statusPort); int maxThreads = Integer.parseInt(System.getProperty(AthenzConsts.ATHENZ_PROP_MAX_THREADS, Integer.toString(AthenzConsts.ATHENZ_HTTP_MAX_THREADS))); container.createServer(maxThreads); HttpConfiguration httpConfig = container.newHttpConfiguration(); container.addHTTPConnectors(httpConfig, httpPort, httpsPort, statusPort); container.addServletHandlers(serverHostName); container.addRequestLogHandler(); return container; } AthenzJettyContainer(); static String getRootDir(); void addRequestLogHandler(); void addServletHandlers(String serverHostName); HttpConfiguration newHttpConfiguration(); void addHTTPConnectors(HttpConfiguration httpConfig, int httpPort, int httpsPort,
            int statusPort); void setBanner(String banner); void createServer(int maxThreads); static AthenzJettyContainer createJettyContainer(); void run(); void stop(); static void main(String [] args);  }
@Test public void testInitContainerStatusPortHTTPS() { System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "4080"); System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "4443"); System.setProperty(AthenzConsts.ATHENZ_PROP_STATUS_PORT, "4444"); AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer(); assertNotNull(container); }
@Test public void testInitContainerStatusPortHTTP() { System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "0"); System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "4080"); System.setProperty(AthenzConsts.ATHENZ_PROP_STATUS_PORT, "4444"); AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer(); assertNotNull(container); }
@Test public void testInitContainerStatusPortNoHTTP() { System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "0"); System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "0"); System.setProperty(AthenzConsts.ATHENZ_PROP_STATUS_PORT, "4444"); AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer(); assertNotNull(container); }
@Test public void testLoadServicePrivateKeyInvalid() { System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "4080"); System.setProperty(AthenzConsts.ATHENZ_PROP_STATUS_PORT, "4444"); System.setProperty(AthenzConsts.ATHENZ_PROP_PRIVATE_KEY_STORE_FACTORY_CLASS, "invalid-class"); try { AthenzJettyContainer.createJettyContainer(); fail(); } catch (Exception ex) { assertTrue(ex instanceof IllegalArgumentException); } }
@Test public void testInvalidJettyHomeDir() { System.setProperty(AthenzConsts.ATHENZ_PROP_JETTY_HOME, "unknown"); try { AthenzJettyContainer.createJettyContainer(); fail(); } catch (Exception ex) { assertTrue(ex instanceof RuntimeException); } System.setProperty(AthenzConsts.ATHENZ_PROP_JETTY_HOME, "conf"); }