Class MockFutureListener
- java.lang.Object
-
- com.google.common.util.concurrent.testing.MockFutureListener
-
- All Implemented Interfaces:
Runnable
@Beta @GwtIncompatible public class MockFutureListener extends Object implements Runnable
A simple mock implementation ofRunnable
that can be used for testing ListenableFutures.- Since:
- 10.0
- Author:
- Nishant Thakkar
-
-
Constructor Summary
Constructors Constructor Description MockFutureListener(com.google.common.util.concurrent.ListenableFuture<?> future)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertException(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(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(com.google.common.util.concurrent.ListenableFuture<?> future)
-
-
Method Detail
-
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 anExecutableException
and that the cause of theExecutableException
isexpectedCause
.- Throws:
Exception
-
assertTimeout
public void assertTimeout() throws Exception
- Throws:
Exception
-
-