@Beta
@GwtIncompatible
public abstract class AbstractListenableFutureTest
extends junit.framework.TestCase
ListenableFuture.
Tests the two get methods and the addListener method.| Modifier and Type | Field and Description |
|---|---|
protected com.google.common.util.concurrent.ListenableFuture<Boolean> |
future |
protected CountDownLatch |
latch |
| Constructor and Description |
|---|
AbstractListenableFutureTest() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract <V> com.google.common.util.concurrent.ListenableFuture<V> |
createListenableFuture(V value,
Exception except,
CountDownLatch waitOn)
Constructs a listenable future with a value available after the latch
has counted down.
|
protected void |
setUp() |
protected void |
tearDown() |
void |
testAllListenersCompleteSuccessfully()
Tests that all listeners complete, even if they were added before or after
the future was finishing.
|
void |
testCanceledFutureThrowsCancellation()
Tests that a canceled future throws a cancellation exception.
|
void |
testGetBlocksUntilValueAvailable()
Tests that the
Future.get() method blocks until a value is
available. |
void |
testListenersNotifiedOnError() |
void |
testTimeoutOnGetWorksCorrectly()
Tests that the
Future.get(long, TimeUnit) method times out
correctly. |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toStringassertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, formatprotected CountDownLatch latch
protected com.google.common.util.concurrent.ListenableFuture<Boolean> future
protected void setUp()
throws Exception
setUp in class junit.framework.TestCaseExceptionprotected void tearDown()
throws Exception
tearDown in class junit.framework.TestCaseExceptionprotected abstract <V> com.google.common.util.concurrent.ListenableFuture<V> createListenableFuture(V value,
Exception except,
CountDownLatch waitOn)
public void testGetBlocksUntilValueAvailable()
throws Throwable
Future.get() method blocks until a value is
available.Throwablepublic void testTimeoutOnGetWorksCorrectly()
throws InterruptedException,
ExecutionException
Future.get(long, TimeUnit) method times out
correctly.public void testCanceledFutureThrowsCancellation()
throws Exception
Exceptionpublic void testListenersNotifiedOnError()
throws Exception
Exceptionpublic void testAllListenersCompleteSuccessfully()
throws InterruptedException,
ExecutionException
Copyright © 2010–2017. All rights reserved.