use of io.helidon.webserver.WebServer in project helidon by oracle.
the class MicrometerEndpointTests method runTest.
private static void runTest(String contextForRequest, Supplier<MicrometerSupport> micrometerSupportSupplier) throws ExecutionException, InterruptedException {
WebServer webServer = null;
try {
webServer = WebServer.builder().host("localhost").port(-1).routing(prepareRouting(micrometerSupportSupplier)).build().start().await();
WebClientResponse webClientResponse = WebClient.builder().baseUri(String.format("http://localhost:%d%s", webServer.port(), contextForRequest)).build().get().accept(MediaType.TEXT_PLAIN).request().get();
MatcherAssert.assertThat(webClientResponse.status(), is(Http.Status.OK_200));
} finally {
if (webServer != null) {
webServer.shutdown().await();
}
}
}
use of io.helidon.webserver.WebServer in project helidon by oracle.
the class MicrometerTestUtil method startServer.
public static WebServer startServer(int port, MicrometerSupport.Builder... builders) throws InterruptedException, ExecutionException, TimeoutException {
WebServer result = WebServer.builder(Routing.builder().register(builders).build()).port(port).build().start().toCompletableFuture().get(10, TimeUnit.SECONDS);
LOGGER.log(Level.INFO, "Started server at: https://localhost:{0}", result.port());
return result;
}
use of io.helidon.webserver.WebServer in project metro-jax-ws by eclipse-ee4j.
the class Main method startServer.
static WebServer startServer() {
setupLogging();
// By default this will pick up application.yaml from the classpath
Config config = buildConfig();
// Get webserver config from the "server" section of application.yaml
WebServer server = WebServer.builder().config(config.get("server")).routing(buildRouting(config)).build();
// Try to start the server. If successful, print some info and arrange to
// print a message at shutdown. If unsuccessful, print the exception.
server.start().thenAccept(ws -> {
System.out.println("WEB server is up! http://localhost:" + ws.port());
ws.whenShutdown().thenRun(() -> System.out.println("WEB server is DOWN. Good bye!"));
}).exceptionally(t -> {
System.err.println("Startup failed: " + t.getMessage());
t.printStackTrace(System.err);
return null;
});
// Server threads are not daemon. No need to block. Just react.
return server;
}
Aggregations