diff options
Diffstat (limited to 'guava-tests/test/com/google/common/util/concurrent/ForwardingListenableFutureTest.java')
-rw-r--r-- | guava-tests/test/com/google/common/util/concurrent/ForwardingListenableFutureTest.java | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/guava-tests/test/com/google/common/util/concurrent/ForwardingListenableFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/ForwardingListenableFutureTest.java index 827f50e..4424e8d 100644 --- a/guava-tests/test/com/google/common/util/concurrent/ForwardingListenableFutureTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/ForwardingListenableFutureTest.java @@ -21,10 +21,48 @@ import junit.framework.TestCase; /** * Tests for {@link ForwardingListenableFuture}. * - * @author Ben Yu + * @author Shardul Deo */ public class ForwardingListenableFutureTest extends TestCase { - public void testForwarding() { - ForwardingObjectTester.testForwardingObject(ForwardingListenableFuture.class); + + private SettableFuture<String> delegate; + private ListenableFuture<String> forwardingFuture; + + private ListenableFutureTester tester; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + delegate = SettableFuture.create(); + forwardingFuture = new ForwardingListenableFuture<String>() { + @Override + protected ListenableFuture<String> delegate() { + return delegate; + } + }; + tester = new ListenableFutureTester(forwardingFuture); + tester.setUp(); + } + + @Override + protected void tearDown() throws Exception { + tester.tearDown(); + super.tearDown(); + } + + public void testCompletedFuture() throws Exception { + delegate.set("foo"); + tester.testCompletedFuture("foo"); + } + + public void testCancelledFuture() throws Exception { + delegate.cancel(true); // parameter is ignored + tester.testCancelledFuture(); + } + + public void testFailedFuture() throws Exception { + delegate.setException(new Exception("failed")); + tester.testFailedFuture("failed"); } } |