@AfterMethod
  public void 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) {
            throw new RuntimeException("Should not be called");
          }

          @Override
          public void onNodeDisconnected(DiscoveryNode node) {
            latch.countDown();
          }
        };
    serviceA.addConnectionListener(disconnectListener);
    serviceB.close();
    assertThat(latch.await(5, TimeUnit.SECONDS), equalTo(true));
  }