Class MockFutureListener
java.lang.Object
com.google.common.util.concurrent.testing.MockFutureListener
- All Implemented Interfaces:
Runnable
A simple mock implementation of
Runnable
that can be used for testing ListenableFutures.- Since:
- 10.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
void
run()
-
Field Details
-
countDownLatch
-
future
-
-
Constructor Details
-
MockFutureListener
-
-
Method Details
-
run
public void run() -
assertSuccess
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
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
- Throws:
Exception
-