Java Code Examples for io.undertow.Undertow#stop()
The following examples show how to use
io.undertow.Undertow#stop() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DelayedHandlerExample.java From StubbornJava with MIT License | 6 votes |
public static void main(String[] args) { SimpleServer server = SimpleServer.simpleServer(getRouter()); server.getUndertow() .setIoThreads(1) .setWorkerThreads(5); Undertow undertow = server.start(); OkHttpClient client = HttpClient.globalClient(); Timers.time("---------- sleep ----------", () -> Http.getInParallel(client, "http://localhost:8080/sleep", 5)); Timers.time("---------- dispatch sleep ----------", () -> Http.getInParallel(client, "http://localhost:8080/dispatch/sleep", 5)); Timers.time("---------- delay ----------", () -> Http.getInParallel(client, "http://localhost:8080/delay", 5)); Timers.time("---------- dispatch delay ----------", () -> Http.getInParallel(client, "http://localhost:8080/dispatch/delay", 5)); undertow.stop(); }
Example 2
Source File: UndertowUtil.java From StubbornJava with MIT License | 6 votes |
/** * This is currently intended to be used in unit tests but may * be appropriate in other situations as well. It's not worth building * out a test module at this time so it lives here. * * This helper will spin up the http handler on a random available port. * The full host and port will be passed to the hostConsumer and the server * will be shut down after the consumer completes. * * @param builder * @param handler * @param hostConusmer */ public static void useLocalServer(Undertow.Builder builder, HttpHandler handler, Consumer<String> hostConusmer) { Undertow undertow = null; try { // Starts server on a random open port undertow = builder.addHttpListener(0, "127.0.0.1", handler).build(); undertow.start(); ListenerInfo listenerInfo = undertow.getListenerInfo().get(0); InetSocketAddress addr = (InetSocketAddress) listenerInfo.getAddress(); String host = "http://localhost:" + addr.getPort(); hostConusmer.accept(host); } finally { if (undertow != null) { undertow.stop(); } } }
Example 3
Source File: DelayedHandlerExample.java From StubbornJava with MIT License | 6 votes |
public static void main(String[] args) { SimpleServer server = SimpleServer.simpleServer(getRouter()); server.getUndertow() .setIoThreads(1) .setWorkerThreads(5); Undertow undertow = server.start(); OkHttpClient client = HttpClient.globalClient(); Timers.time("---------- sleep ----------", () -> Http.getInParallel(client, "http://localhost:8080/sleep", 5)); Timers.time("---------- dispatch sleep ----------", () -> Http.getInParallel(client, "http://localhost:8080/dispatch/sleep", 5)); Timers.time("---------- delay ----------", () -> Http.getInParallel(client, "http://localhost:8080/delay", 5)); Timers.time("---------- dispatch delay ----------", () -> Http.getInParallel(client, "http://localhost:8080/dispatch/delay", 5)); undertow.stop(); }
Example 4
Source File: UndertowUtil.java From StubbornJava with MIT License | 6 votes |
/** * This is currently intended to be used in unit tests but may * be appropriate in other situations as well. It's not worth building * out a test module at this time so it lives here. * * This helper will spin up the http handler on a random available port. * The full host and port will be passed to the hostConsumer and the server * will be shut down after the consumer completes. * * @param builder * @param handler * @param hostConusmer */ public static void useLocalServer(Undertow.Builder builder, HttpHandler handler, Consumer<String> hostConusmer) { Undertow undertow = null; try { // Starts server on a random open port undertow = builder.addHttpListener(0, "127.0.0.1", handler).build(); undertow.start(); ListenerInfo listenerInfo = undertow.getListenerInfo().get(0); InetSocketAddress addr = (InetSocketAddress) listenerInfo.getAddress(); String host = "http://localhost:" + addr.getPort(); hostConusmer.accept(host); } finally { if (undertow != null) { undertow.stop(); } } }
Example 5
Source File: StopTestCase.java From quarkus-http with Apache License 2.0 | 5 votes |
@Test public void testStopUndertowAfterExceptionDuringStart() { // Making the NioXnioWorker constructor throw an exception, resulting in the Undertow.worker field not getting set. Undertow undertow = Undertow.builder().build(); try { undertow.start(); } catch (RuntimeException e) { } undertow.stop(); }