@Test public void testShutDown() throws Exception { TestResponse response = TestClient.create(Main.createRouting()) .path("/mgmt/shutdown") .post(); assertEquals(Http.Status.OK_200, response.status()); CountDownLatch latch = new CountDownLatch(1); WebServer webServer = response.webServer(); webServer .whenShutdown() .thenRun(latch::countDown); assertTrue(latch.await(10, TimeUnit.SECONDS)); }
static Routing createRouting() { UpperXFilter upperXFilter = new UpperXFilter(); return Routing.builder() .any(new UserFilter()) .any((req, res) -> { res.registerFilter(upperXFilter); req.next(); }) .register("/article", new CommentService()) .post("/mgmt/shutdown", (req, res) -> { res.headers().contentType(MediaType.TEXT_PLAIN.withCharset("UTF-8")); res.send("Shutting down TUTORIAL server. Good bye!\n"); res.whenSent().thenRun(() -> req.webServer().shutdown()); }) .build(); }
Main { static Routing createRouting() { UpperXFilter upperXFilter = new UpperXFilter(); return Routing.builder() .any(new UserFilter()) .any((req, res) -> { res.registerFilter(upperXFilter); req.next(); }) .register("/article", new CommentService()) .post("/mgmt/shutdown", (req, res) -> { res.headers().contentType(MediaType.TEXT_PLAIN.withCharset("UTF-8")); res.send("Shutting down TUTORIAL server. Good bye!\n"); res.whenSent().thenRun(() -> req.webServer().shutdown()); }) .build(); } }
Main { static Routing createRouting() { UpperXFilter upperXFilter = new UpperXFilter(); return Routing.builder() .any(new UserFilter()) .any((req, res) -> { res.registerFilter(upperXFilter); req.next(); }) .register("/article", new CommentService()) .post("/mgmt/shutdown", (req, res) -> { res.headers().contentType(MediaType.TEXT_PLAIN.withCharset("UTF-8")); res.send("Shutting down TUTORIAL server. Good bye!\n"); res.whenSent().thenRun(() -> req.webServer().shutdown()); }) .build(); } private  Main(); }
Main { static Routing createRouting() { UpperXFilter upperXFilter = new UpperXFilter(); return Routing.builder() .any(new UserFilter()) .any((req, res) -> { res.registerFilter(upperXFilter); req.next(); }) .register("/article", new CommentService()) .post("/mgmt/shutdown", (req, res) -> { res.headers().contentType(MediaType.TEXT_PLAIN.withCharset("UTF-8")); res.send("Shutting down TUTORIAL server. Good bye!\n"); res.whenSent().thenRun(() -> req.webServer().shutdown()); }) .build(); } private  Main(); static void main(String[] args); }
Main { static Routing createRouting() { UpperXFilter upperXFilter = new UpperXFilter(); return Routing.builder() .any(new UserFilter()) .any((req, res) -> { res.registerFilter(upperXFilter); req.next(); }) .register("/article", new CommentService()) .post("/mgmt/shutdown", (req, res) -> { res.headers().contentType(MediaType.TEXT_PLAIN.withCharset("UTF-8")); res.send("Shutting down TUTORIAL server. Good bye!\n"); res.whenSent().thenRun(() -> req.webServer().shutdown()); }) .build(); } private  Main(); static void main(String[] args);  }