ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/CompletableFutureTest.java
Revision: 1.2
Committed: Wed Feb 6 20:29:55 2013 UTC (11 years, 3 months ago) by jsr166
Branch: MAIN
Changes since 1.1: +4 -2 lines
Log Message:
testToString

File Contents

# User Rev Content
1 jsr166 1.1 /*
2     * Written by Doug Lea with assistance from members of JCP JSR-166
3     * Expert Group and released to the public domain, as explained at
4     * http://creativecommons.org/publicdomain/zero/1.0/
5     * Other contributors include Andrew Wright, Jeffrey Hayes,
6     * Pat Fisher, Mike Judd.
7     */
8    
9     import junit.framework.*;
10     import java.util.concurrent.Callable;
11     import java.util.concurrent.CancellationException;
12     import java.util.concurrent.CountDownLatch;
13     import java.util.concurrent.ExecutionException;
14     import java.util.concurrent.Future;
15     import java.util.concurrent.CompletableFuture;
16     import java.util.concurrent.TimeoutException;
17     import java.util.concurrent.atomic.AtomicInteger;
18     import static java.util.concurrent.TimeUnit.MILLISECONDS;
19     import static java.util.concurrent.TimeUnit.SECONDS;
20     import java.util.*;
21    
22     public class CompletableFutureTest extends JSR166TestCase {
23    
24     public static void main(String[] args) {
25     junit.textui.TestRunner.run(suite());
26     }
27     public static Test suite() {
28     return new TestSuite(CompletableFutureTest.class);
29     }
30    
31     public void testToString() {
32     CompletableFuture<String> f;
33 jsr166 1.2
34 jsr166 1.1 f = new CompletableFuture<String>();
35 jsr166 1.2 assertTrue(f.toString().contains("[Not completed]"));
36    
37 jsr166 1.1 f.complete("foo");
38     assertTrue(f.toString().contains("[Completed normally]"));
39 jsr166 1.2
40 jsr166 1.1 f = new CompletableFuture<String>();
41     f.completeExceptionally(new IndexOutOfBoundsException());
42     assertTrue(f.toString().contains("[Completed exceptionally]"));
43     }
44     }