@After public void tearDown() throws Exception { super.tearDown(); serviceA.close(); serviceB.close(); threadPool.shutdown(); }
@Test public void testDisconnectListener() throws Exception { final CountDownLatch latch = new CountDownLatch(1); TransportConnectionListener disconnectListener = new TransportConnectionListener() { @Override public void onNodeConnected(DiscoveryNode node) { fail( "node connected should not be called, all connection have been done previously, node: " + node); } @Override public void onNodeDisconnected(DiscoveryNode node) { latch.countDown(); } }; serviceA.addConnectionListener(disconnectListener); serviceB.close(); assertThat(latch.await(5, TimeUnit.SECONDS), equalTo(true)); }