コード例 #1
0
ファイル: AsyncClientTest.java プロジェクト: asdlei00/swift-2
    @Override
    public void onSuccess(DelayedMap.AsyncClient client) {
      try {
        getBeforeFuture = client.getValueSlowly(200, TimeUnit.MILLISECONDS, "testKey");
        putFuture = client.putValueSlowly(400, TimeUnit.MILLISECONDS, "testKey", "testValue");
        getAfterFuture = client.getValueSlowly(600, TimeUnit.MILLISECONDS, "testKey");
      } catch (Throwable t) {
        onFailure(t);
      }

      latch.countDown();
    }
コード例 #2
0
ファイル: AsyncClientTest.java プロジェクト: asdlei00/swift-2
  @Test
  public void testAsyncOutOfOrder() throws Exception {
    ListenableFuture<String> getFuture;
    ListenableFuture<Void> putFuture;

    try (DelayedMap.AsyncClient client =
        createClient(DelayedMap.AsyncClient.class, syncServer).get()) {
      getFuture = client.getValueSlowly(500, TimeUnit.MILLISECONDS, "testKey");
      putFuture = client.putValueSlowly(250, TimeUnit.MILLISECONDS, "testKey", "testValue");

      assertEquals(getFuture.get(1, TimeUnit.SECONDS), "testValue");
      putFuture.get(1, TimeUnit.SECONDS);
    }
  }
コード例 #3
0
ファイル: AsyncClientTest.java プロジェクト: asdlei00/swift-2
  @Test
  public void testAsyncClient() throws Exception {
    ListenableFuture<String> getBeforeFuture;
    ListenableFuture<String> getAfterFuture;
    ListenableFuture<Void> putFuture;

    try (DelayedMap.AsyncClient client =
        createClient(DelayedMap.AsyncClient.class, syncServer).get()) {
      getBeforeFuture = client.getValueSlowly(200, TimeUnit.MILLISECONDS, "testKey");
      putFuture = client.putValueSlowly(400, TimeUnit.MILLISECONDS, "testKey", "testValue");
      getAfterFuture = client.getValueSlowly(600, TimeUnit.MILLISECONDS, "testKey");

      assertEquals(Uninterruptibles.getUninterruptibly(getBeforeFuture), "default");
      assertEquals(Uninterruptibles.getUninterruptibly(getAfterFuture), "testValue");
      Uninterruptibles.getUninterruptibly(putFuture);
    }
  }