@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 ListenableFuture<java.lang.Boolean> |
future |
protected java.util.concurrent.CountDownLatch |
latch |
Constructor and Description |
---|
AbstractListenableFutureTest() |
Modifier and Type | Method and Description |
---|---|
protected abstract <V> ListenableFuture<V> |
createListenableFuture(V value,
java.lang.Exception except,
java.util.concurrent.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. |
assertEquals, 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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, toString
protected java.util.concurrent.CountDownLatch latch
protected ListenableFuture<java.lang.Boolean> future
public AbstractListenableFutureTest()
protected void setUp() throws java.lang.Exception
setUp
in class junit.framework.TestCase
java.lang.Exception
protected void tearDown() throws java.lang.Exception
tearDown
in class junit.framework.TestCase
java.lang.Exception
protected abstract <V> ListenableFuture<V> createListenableFuture(V value, java.lang.Exception except, java.util.concurrent.CountDownLatch waitOn)
public void testGetBlocksUntilValueAvailable() throws java.lang.Throwable
Future.get()
method blocks until a value is available.java.lang.Throwable
public void testTimeoutOnGetWorksCorrectly() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
Future.get(long, TimeUnit)
method times out correctly.java.lang.InterruptedException
java.util.concurrent.ExecutionException
public void testCanceledFutureThrowsCancellation() throws java.lang.Exception
This method checks the cancel, isCancelled, and isDone methods.
java.lang.Exception
public void testListenersNotifiedOnError() throws java.lang.Exception
java.lang.Exception
public void testAllListenersCompleteSuccessfully() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
Copyright © 2010-2018. All Rights Reserved.