@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 server.close(); CountDownLatch latch = new CountDownLatch(1); server = vertx.createNetServer(); server.connectHandler(sock -> { fail("Should not connect"); }).listen(testAddress, ar -> { if (ar.succeeded()) { latch.countDown(); } else { fail("Failed to bind server"); } }); awaitLatch(latch); CountDownLatch closeLatch = new CountDownLatch(1); server.close(ar -> { assertTrue(ar.succeeded()); closeLatch.countDown(); }); assertTrue(closeLatch.await(10, TimeUnit.SECONDS)); testSharedServersRoundRobin(); }
@Test public void testSharedServersRoundRobinWithOtherServerRunningOnDifferentPort() throws Exception { CountDownLatch latch = new CountDownLatch(1); // Have a server running on a different port to make sure it doesn't interact server.close(); server = vertx.createNetServer(new NetServerOptions().setPort(4321)); server.connectHandler(sock -> { fail("Should not connect"); }).listen(ar2 -> { if (ar2.succeeded()) { latch.countDown(); } else { fail("Failed to bind server"); } }); 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 server.close(); CountDownLatch latch = new CountDownLatch(1); server = vertx.createNetServer(); server.connectHandler(sock -> { fail("Should not connect"); }).listen(testAddress, ar -> { if (ar.succeeded()) { latch.countDown(); } else { fail("Failed to bind server"); } }); awaitLatch(latch); CountDownLatch closeLatch = new CountDownLatch(1); server.close(ar -> { assertTrue(ar.succeeded()); closeLatch.countDown(); }); assertTrue(closeLatch.await(10, TimeUnit.SECONDS)); testSharedServersRoundRobin(); }
@Test public void testSharedServersRoundRobinWithOtherServerRunningOnDifferentPort() throws Exception { CountDownLatch latch = new CountDownLatch(1); // Have a server running on a different port to make sure it doesn't interact server.close(); server = vertx.createNetServer(new NetServerOptions().setPort(4321)); server.connectHandler(sock -> { fail("Should not connect"); }).listen(ar2 -> { if (ar2.succeeded()) { latch.countDown(); } else { fail("Failed to bind server"); } }); awaitLatch(latch); testSharedServersRoundRobin(); }