@Test
  public void testSyncGetTimeouts() throws Exception {
    final String key = "timeoutTestKey";
    final String value = "timeoutTestValue";

    int j = 0;
    boolean set = false;

    // Do not execute this for CI
    if (TestConfig.isCITest()) {
      return;
    }

    do {
      set = client.set(key, 0, value).get();
      j++;
    } while (!set && j < 10);
    assert set;

    // Shutting down the default client to get one with a short timeout.
    assertTrue("Couldn't shut down within five seconds", client.shutdown(5, TimeUnit.SECONDS));

    syncGetTimeoutsInitClient();
    Thread.sleep(100); // allow connections to be established

    int i = 0;
    GetFuture<Object> g = null;
    try {
      for (i = 0; i < 1000000; i++) {
        g = client.asyncGet(key);
        g.get();
      }
      throw new Exception("Didn't get a timeout.");
    } catch (Exception e) {
      assert !g.getStatus().isSuccess();
      System.err.println("Got a timeout at iteration " + i + ".");
    }
    Thread.sleep(100); // let whatever caused the timeout to pass
    try {
      if (value.equals(client.asyncGet(key).get(30, TimeUnit.SECONDS))) {
        System.err.println("Got the right value.");
      } else {
        throw new Exception("Didn't get the expected value.");
      }
    } catch (java.util.concurrent.TimeoutException timeoutException) {
      debugNodeInfo(client.getNodeLocator().getAll());
      throw new Exception("Unexpected timeout after 30 seconds waiting", timeoutException);
    }
  }
  @Test
  public void testGetWithCallback() throws Exception {
    client.set("getWithCallback", 0, "content").get();

    GetFuture<Object> getOp = client.asyncGet("getWithCallback");

    final CountDownLatch latch = new CountDownLatch(1);
    getOp.addListener(
        new GetCompletionListener() {
          @Override
          public void onComplete(GetFuture<?> f) throws Exception {
            latch.countDown();
          }
        });

    assertTrue(latch.await(2, TimeUnit.SECONDS));
  }
 @Test
 public void testABunchOfCancelledOperations() throws Exception {
   final String k = "bunchOCancel";
   Collection<Future<?>> futures = new ArrayList<Future<?>>();
   for (int i = 0; i < 1000; i++) {
     futures.add(client.set(k, 5, "xval"));
     futures.add(client.asyncGet(k));
   }
   OperationFuture<Boolean> sf = client.set(k, 5, "myxval");
   GetFuture<Object> gf = client.asyncGet(k);
   for (Future<?> f : futures) {
     f.cancel(true);
   }
   assertTrue(sf.get());
   assert sf.getStatus().isSuccess();
   assertEquals("myxval", gf.get());
   assert gf.getStatus().isSuccess();
 }