com.google.common.util.concurrent.testing
Class MockFutureListener

java.lang.Object
  extended by com.google.common.util.concurrent.testing.MockFutureListener
All Implemented Interfaces:
Runnable

@Beta
public class MockFutureListener
extends Object
implements Runnable

A simple mock implementation of Runnable that can be used for testing ListenableFutures.

Since:
10.0
Author:
Nishant Thakkar

Constructor Summary
MockFutureListener(ListenableFuture<?> future)
           
 
Method Summary
 void assertException(Throwable expectedCause)
          Verify that the listener completes in a reasonable amount of time, and Asserts that the future throws an ExecutableException and that the cause of the ExecutableException is expectedCause.
 void assertSuccess(Object expectedData)
          Verify that the listener completes in a reasonable amount of time, and Asserts that the future returns the expected data.
 void assertTimeout()
           
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockFutureListener

public MockFutureListener(ListenableFuture<?> future)
Method Detail

run

public void run()
Specified by:
run in interface Runnable

assertSuccess

public void assertSuccess(Object expectedData)
                   throws Throwable
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.

assertException

public void assertException(Throwable expectedCause)
                     throws Exception
Verify that the listener completes in a reasonable amount of time, and Asserts that the future throws an ExecutableException and that the cause of the ExecutableException is expectedCause.

Throws:
Exception

assertTimeout

public void assertTimeout()
                   throws Exception
Throws:
Exception


Copyright © 2010-2012. All Rights Reserved.