コード例 #1
0
ファイル: AsyncClientTest.java プロジェクト: asdlei00/swift-2
  @Test
  public void testAsyncOneWay()
      throws InterruptedException, ExecutionException, TTransportException, IOException {
    final CountDownLatch latch = new CountDownLatch(1);

    try (DelayedMap.AsyncClient client =
        createClient(DelayedMap.AsyncClient.class, syncServer).get()) {
      ListenableFuture<Void> onewayFuture =
          client.onewayPutValueSlowly(100, TimeUnit.MILLISECONDS, "testKey", "testValue");

      Futures.addCallback(
          onewayFuture,
          new FutureCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
              latch.countDown();
            }

            @Override
            public void onFailure(Throwable t) {
              fail("Async call to onewayPutValueSlowly failed", t);
            }
          });

      assertTrue(latch.await(500, TimeUnit.MILLISECONDS));
    }
  }