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 ofRunnable
that 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 void
assertException(java.lang.Throwable expectedCause)
Verify that the listener completes in a reasonable amount of time, and Asserts that the future throws anExecutableException
and that the cause of theExecutableException
isexpectedCause
.void
assertSuccess(java.lang.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()
-
-
-
Constructor Detail
-
MockFutureListener
public MockFutureListener(ListenableFuture<?> future)
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
assertSuccess
public void assertSuccess(java.lang.Object expectedData) throws java.lang.Throwable
Verify 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.Exception
Verify that the listener completes in a reasonable amount of time, and Asserts that the future throws anExecutableException
and that the cause of theExecutableException
isexpectedCause
.- Throws:
java.lang.Exception
-
assertTimeout
public void assertTimeout() throws java.lang.Exception
- Throws:
java.lang.Exception
-
-