Class MockFutureListener
- java.lang.Object
-
- com.google.common.util.concurrent.testing.MockFutureListener
-
- All Implemented Interfaces:
java.lang.Runnable
@Beta @GwtIncompatible public class MockFutureListener extends java.lang.Object implements java.lang.Runnable
A simple mock implementation ofRunnablethat can be used for testing ListenableFutures.- Since:
- 10.0
-
-
Constructor Summary
Constructors Constructor Description MockFutureListener(ListenableFuture<?> future)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertException(java.lang.Throwable expectedCause)Verify that the listener completes in a reasonable amount of time, and Asserts that the future throws anExecutableExceptionand that the cause of theExecutableExceptionisexpectedCause.voidassertSuccess(java.lang.Object expectedData)Verify that the listener completes in a reasonable amount of time, and Asserts that the future returns the expected data.voidassertTimeout()voidrun()
-
-
-
Constructor Detail
-
MockFutureListener
public MockFutureListener(ListenableFuture<?> future)
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
assertSuccess
public void assertSuccess(java.lang.Object expectedData) throws java.lang.ThrowableVerify that the listener completes in a reasonable amount of time, and Asserts that the future returns the expected data.- Throws:
java.lang.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(java.lang.Throwable expectedCause) throws java.lang.ExceptionVerify that the listener completes in a reasonable amount of time, and Asserts that the future throws anExecutableExceptionand that the cause of theExecutableExceptionisexpectedCause.- Throws:
java.lang.Exception
-
assertTimeout
public void assertTimeout() throws java.lang.Exception- Throws:
java.lang.Exception
-
-