Code example for ListenableFuture

Methods: addListener

  public MockFutureListener(ListenableFuture<?> future) {
    this.countDownLatch = new CountDownLatch(1);
    this.future = future;
    future.addListener(this, MoreExecutors.sameThreadExecutor());
  public void run() { 
   * Verify that the listener completes in a reasonable amount of time, and 
   * Asserts that the future returns the expected data. 
   * @throws Throwable if the listener isn't called or if it resulted in a 
   *     throwable or if the result doesn't match the expected value. 
  public void assertSuccess(Object expectedData) throws Throwable {