コード例 #1
0
  @AfterMethod
  public void tearDown() {
    serviceA.close();
    serviceB.close();

    threadPool.shutdown();
  }
コード例 #2
0
  @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));
  }