@Beta @GwtIncompatible public class MockFutureListener extends java.lang.Object implements java.lang.Runnable
Runnable that can be used for
testing ListenableFutures.| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.CountDownLatch |
countDownLatch |
private ListenableFuture<?> |
future |
| Constructor and Description |
|---|
MockFutureListener(ListenableFuture<?> future) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertException(java.lang.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(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() |
private final java.util.concurrent.CountDownLatch countDownLatch
private final ListenableFuture<?> future
public MockFutureListener(ListenableFuture<?> future)
public void run()
run in interface java.lang.Runnablepublic void assertSuccess(java.lang.Object expectedData)
throws java.lang.Throwable
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.public void assertException(java.lang.Throwable expectedCause)
throws java.lang.Exception
ExecutableException and that the
cause of the ExecutableException is expectedCause.java.lang.Exceptionpublic void assertTimeout()
throws java.lang.Exception
java.lang.Exception