ServerFactory { public HttpServer build() { Configuration config = configBuilder.build(); HttpServer server = createServer(config); for (Entry<String, ResourceConfig> route : services.entrySet()) { String path = route.getKey(); ResourceConfig rc = route.getValue(); rc.register(new ConfigurationBinder(config)); String name = route.getValue().getClass().getSimpleName(); WebappContext context = new WebappContext(name, path); ServletRegistration registration = context.addServlet(name, new ServletContainer(rc)); registration.setInitParameter("swagger.context.id", name); registration.addMapping(String.format("%s/*", path)); context.deploy(server); } String htmlAppRoot = config.getString(Config.HTML_APP_ROOT.getKey(), Config.HTML_APP_ROOT.getValue()); if (!Strings.isNullOrEmpty(htmlAppRoot)) { HtmlApplicationHttpHandler handler = new HtmlApplicationHttpHandler(htmlAppRoot); handler.setFileCacheEnabled(true); server.getServerConfiguration().addHttpHandler(handler, "/*"); } return server; } ServerFactory(); ServerFactory withCommandlineOptions(final Options options); ServerFactory withCommandlineArgs(final String[] args); ServerFactory withPropertiesFile(final String path); ServerFactory withResource(final String s,
                                      final ResourceConfig resource); HttpServer build(); ServerFactory configureServer(final ServerOperator serverLambda); static final Options CLI_OPTIONS; }
@Test public void testSimpleBuild() { ServerFactory f = new ServerFactory(); HttpServer s = f.build(); assertNotNull(s); }