ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/CompletableFutureTest.java
(Generate patch)

Comparing jsr166/src/test/tck/CompletableFutureTest.java (file contents):
Revision 1.68 by jsr166, Fri Jun 6 19:35:54 2014 UTC vs.
Revision 1.69 by jsr166, Fri Jun 6 19:39:50 2014 UTC

# Line 2368 | Line 2368 | public class CompletableFutureTest exten
2368          for (int i = 0; i < 4; i++) rs[i].assertNotInvoked();
2369      }}
2370  
2371 +    public void testRunAfterEither_exceptionalCompletion2() {
2372 +        for (ExecutionMode m : ExecutionMode.values())
2373 +        for (boolean fFirst : new boolean[] { true, false })
2374 +        for (Integer v1 : new Integer[] { 1, null })
2375 +    {
2376 +        final CompletableFuture<Integer> f = new CompletableFuture<>();
2377 +        final CompletableFuture<Integer> g = new CompletableFuture<>();
2378 +        final CFException ex = new CFException();
2379 +        final Noop[] rs = new Noop[6];
2380 +        for (int i = 0; i < rs.length; i++) rs[i] = new Noop(m);
2381 +
2382 +        final CompletableFuture<Void> h0 = m.runAfterEither(f, g, rs[0]);
2383 +        final CompletableFuture<Void> h1 = m.runAfterEither(g, f, rs[1]);
2384 +        if (fFirst) {
2385 +            f.complete(v1);
2386 +            g.completeExceptionally(ex);
2387 +        } else {
2388 +            g.completeExceptionally(ex);
2389 +            f.complete(v1);
2390 +        }
2391 +        final CompletableFuture<Void> h2 = m.runAfterEither(f, g, rs[2]);
2392 +        final CompletableFuture<Void> h3 = m.runAfterEither(g, f, rs[3]);
2393 +
2394 +        // unspecified behavior - both source completions available
2395 +        try {
2396 +            assertEquals(null, h0.join());
2397 +            rs[0].assertInvoked();
2398 +        } catch (CompletionException ok) {
2399 +            checkCompletedWithWrappedCFException(h0, ex);
2400 +            rs[0].assertNotInvoked();
2401 +        }
2402 +        try {
2403 +            assertEquals(null, h1.join());
2404 +            rs[1].assertInvoked();
2405 +        } catch (CompletionException ok) {
2406 +            checkCompletedWithWrappedCFException(h1, ex);
2407 +            rs[1].assertNotInvoked();
2408 +        }
2409 +        try {
2410 +            assertEquals(null, h2.join());
2411 +            rs[2].assertInvoked();
2412 +        } catch (CompletionException ok) {
2413 +            checkCompletedWithWrappedCFException(h2, ex);
2414 +            rs[2].assertNotInvoked();
2415 +        }
2416 +        try {
2417 +            assertEquals(null, h3.join());
2418 +            rs[3].assertInvoked();
2419 +        } catch (CompletionException ok) {
2420 +            checkCompletedWithWrappedCFException(h3, ex);
2421 +            rs[3].assertNotInvoked();
2422 +        }
2423 +
2424 +        checkCompletedNormally(f, v1);
2425 +        checkCompletedWithWrappedCFException(g, ex);
2426 +    }}
2427 +
2428      /**
2429       * runAfterEither result completes exceptionally if either source cancelled
2430       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines