@Test public void testSharedServersRoundRobinWithOtherServerRunningOnDifferentPort() throws Exception { // Have a server running on a different port to make sure it doesn't interact CountDownLatch latch = new CountDownLatch(1); HttpServer theServer = vertx.createHttpServer(new HttpServerOptions().setPort(8081)); theServer.requestHandler(req -> { fail("Should not process request"); }).listen(onSuccess(s -> latch.countDown())); awaitLatch(latch); testSharedServersRoundRobin(); }
@Test public void testSharedServersRoundRobinButFirstStartAndStopServer() throws Exception { // Start and stop a server on the same port/host before hand to make sure it doesn't interact CountDownLatch latch = new CountDownLatch(1); HttpServer theServer = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT)); theServer.requestHandler(req -> { fail("Should not process request"); }).listen(onSuccess(s -> latch.countDown())); awaitLatch(latch); CountDownLatch closeLatch = new CountDownLatch(1); theServer.close(ar -> { assertTrue(ar.succeeded()); closeLatch.countDown(); }); assertTrue(closeLatch.await(10, TimeUnit.SECONDS)); testSharedServersRoundRobin(); }
@Test public void testSharedServersRoundRobinWithOtherServerRunningOnDifferentPort() throws Exception { // Have a server running on a different port to make sure it doesn't interact CountDownLatch latch = new CountDownLatch(1); HttpServer theServer = vertx.createHttpServer(new HttpServerOptions().setPort(8081)); theServer.requestHandler(req -> { fail("Should not process request"); }).listen(onSuccess(s -> latch.countDown())); awaitLatch(latch); testSharedServersRoundRobin(); }
@Test public void testSharedServersRoundRobinButFirstStartAndStopServer() throws Exception { // Start and stop a server on the same port/host before hand to make sure it doesn't interact CountDownLatch latch = new CountDownLatch(1); HttpServer theServer = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT)); theServer.requestHandler(req -> { fail("Should not process request"); }).listen(onSuccess(s -> latch.countDown())); awaitLatch(latch); CountDownLatch closeLatch = new CountDownLatch(1); theServer.close(ar -> { assertTrue(ar.succeeded()); closeLatch.countDown(); }); assertTrue(closeLatch.await(10, TimeUnit.SECONDS)); testSharedServersRoundRobin(); }