Esempio n. 1
0
    @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();
    }
Esempio n. 2
0
  @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);
    }
  }
Esempio n. 3
0
  @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);
    }
  }