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.150 by jsr166, Sun Jun 26 16:37:28 2016 UTC vs.
Revision 1.151 by jsr166, Sun Jun 26 17:45:35 2016 UTC

# Line 459 | Line 459 | public class CompletableFutureTest exten
459      class FailingSupplier extends CheckedAction
460          implements Supplier<Integer>
461      {
462 <        FailingSupplier(ExecutionMode m) { super(m); }
462 >        final CFException ex;
463 >        FailingSupplier(ExecutionMode m) { super(m); ex = new CFException(); }
464          public Integer get() {
465              invoked();
466 <            throw new CFException();
466 >            throw ex;
467          }
468      }
469  
470      class FailingConsumer extends CheckedIntegerAction
471          implements Consumer<Integer>
472      {
473 <        FailingConsumer(ExecutionMode m) { super(m); }
473 >        final CFException ex;
474 >        FailingConsumer(ExecutionMode m) { super(m); ex = new CFException(); }
475          public void accept(Integer x) {
476              invoked();
477              value = x;
478 <            throw new CFException();
478 >            throw ex;
479          }
480      }
481  
482      class FailingBiConsumer extends CheckedIntegerAction
483          implements BiConsumer<Integer, Integer>
484      {
485 <        FailingBiConsumer(ExecutionMode m) { super(m); }
485 >        final CFException ex;
486 >        FailingBiConsumer(ExecutionMode m) { super(m); ex = new CFException(); }
487          public void accept(Integer x, Integer y) {
488              invoked();
489              value = subtract(x, y);
490 <            throw new CFException();
490 >            throw ex;
491          }
492      }
493  
494      class FailingFunction extends CheckedIntegerAction
495          implements Function<Integer, Integer>
496      {
497 <        FailingFunction(ExecutionMode m) { super(m); }
497 >        final CFException ex;
498 >        FailingFunction(ExecutionMode m) { super(m); ex = new CFException(); }
499          public Integer apply(Integer x) {
500              invoked();
501              value = x;
502 <            throw new CFException();
502 >            throw ex;
503          }
504      }
505  
506      class FailingBiFunction extends CheckedIntegerAction
507          implements BiFunction<Integer, Integer, Integer>
508      {
509 <        FailingBiFunction(ExecutionMode m) { super(m); }
509 >        final CFException ex;
510 >        FailingBiFunction(ExecutionMode m) { super(m); ex = new CFException(); }
511          public Integer apply(Integer x, Integer y) {
512              invoked();
513              value = subtract(x, y);
514 <            throw new CFException();
514 >            throw ex;
515          }
516      }
517  
518      class FailingRunnable extends CheckedAction implements Runnable {
519 <        FailingRunnable(ExecutionMode m) { super(m); }
519 >        final CFException ex;
520 >        FailingRunnable(ExecutionMode m) { super(m); ex = new CFException(); }
521          public void run() {
522              invoked();
523 <            throw new CFException();
523 >            throw ex;
524          }
525      }
526  
# Line 534 | Line 540 | public class CompletableFutureTest exten
540      class FailingCompletableFutureFunction extends CheckedIntegerAction
541          implements Function<Integer, CompletableFuture<Integer>>
542      {
543 <        FailingCompletableFutureFunction(ExecutionMode m) { super(m); }
543 >        final CFException ex;
544 >        FailingCompletableFutureFunction(ExecutionMode m) { super(m); ex = new CFException(); }
545          public CompletableFuture<Integer> apply(Integer x) {
546              invoked();
547              value = x;
548 <            throw new CFException();
548 >            throw ex;
549          }
550      }
551  
# Line 1222 | Line 1229 | public class CompletableFutureTest exten
1229      {
1230          final FailingRunnable r = new FailingRunnable(m);
1231          final CompletableFuture<Void> f = m.runAsync(r);
1232 <        checkCompletedWithWrappedCFException(f);
1232 >        checkCompletedWithWrappedException(f, r.ex);
1233          r.assertInvoked();
1234      }}
1235  
# Line 1256 | Line 1263 | public class CompletableFutureTest exten
1263      {
1264          FailingSupplier r = new FailingSupplier(m);
1265          CompletableFuture<Integer> f = m.supplyAsync(r);
1266 <        checkCompletedWithWrappedCFException(f);
1266 >        checkCompletedWithWrappedException(f, r.ex);
1267          r.assertInvoked();
1268      }}
1269  
# Line 1378 | Line 1385 | public class CompletableFutureTest exten
1385          final CompletableFuture<Void> h4 = m.runAfterBoth(f, f, rs[4]);
1386          final CompletableFuture<Void> h5 = m.runAfterEither(f, f, rs[5]);
1387  
1388 <        checkCompletedWithWrappedCFException(h0);
1389 <        checkCompletedWithWrappedCFException(h1);
1390 <        checkCompletedWithWrappedCFException(h2);
1391 <        checkCompletedWithWrappedCFException(h3);
1392 <        checkCompletedWithWrappedCFException(h4);
1393 <        checkCompletedWithWrappedCFException(h5);
1388 >        checkCompletedWithWrappedException(h0, rs[0].ex);
1389 >        checkCompletedWithWrappedException(h1, rs[1].ex);
1390 >        checkCompletedWithWrappedException(h2, rs[2].ex);
1391 >        checkCompletedWithWrappedException(h3, rs[3].ex);
1392 >        checkCompletedWithWrappedException(h4, rs[4].ex);
1393 >        checkCompletedWithWrappedException(h5, rs[5].ex);
1394          checkCompletedNormally(f, v1);
1395      }}
1396  
# Line 1482 | Line 1489 | public class CompletableFutureTest exten
1489          final CompletableFuture<Integer> h2 = m.thenApply(f, rs[2]);
1490          final CompletableFuture<Integer> h3 = m.applyToEither(f, f, rs[3]);
1491  
1492 <        checkCompletedWithWrappedCFException(h0);
1493 <        checkCompletedWithWrappedCFException(h1);
1494 <        checkCompletedWithWrappedCFException(h2);
1495 <        checkCompletedWithWrappedCFException(h3);
1492 >        checkCompletedWithWrappedException(h0, rs[0].ex);
1493 >        checkCompletedWithWrappedException(h1, rs[1].ex);
1494 >        checkCompletedWithWrappedException(h2, rs[2].ex);
1495 >        checkCompletedWithWrappedException(h3, rs[3].ex);
1496          checkCompletedNormally(f, v1);
1497      }}
1498  
# Line 1584 | Line 1591 | public class CompletableFutureTest exten
1591          final CompletableFuture<Void> h2 = m.thenAccept(f, rs[2]);
1592          final CompletableFuture<Void> h3 = m.acceptEither(f, f, rs[3]);
1593  
1594 <        checkCompletedWithWrappedCFException(h0);
1595 <        checkCompletedWithWrappedCFException(h1);
1596 <        checkCompletedWithWrappedCFException(h2);
1597 <        checkCompletedWithWrappedCFException(h3);
1594 >        checkCompletedWithWrappedException(h0, rs[0].ex);
1595 >        checkCompletedWithWrappedException(h1, rs[1].ex);
1596 >        checkCompletedWithWrappedException(h2, rs[2].ex);
1597 >        checkCompletedWithWrappedException(h3, rs[3].ex);
1598          checkCompletedNormally(f, v1);
1599      }}
1600  
# Line 1749 | Line 1756 | public class CompletableFutureTest exten
1756          assertTrue(snd.complete(w2));
1757          final CompletableFuture<Integer> h3 = m.thenCombine(f, g, r3);
1758  
1759 <        checkCompletedWithWrappedCFException(h1);
1760 <        checkCompletedWithWrappedCFException(h2);
1761 <        checkCompletedWithWrappedCFException(h3);
1759 >        checkCompletedWithWrappedException(h1, r1.ex);
1760 >        checkCompletedWithWrappedException(h2, r2.ex);
1761 >        checkCompletedWithWrappedException(h3, r3.ex);
1762          r1.assertInvoked();
1763          r2.assertInvoked();
1764          r3.assertInvoked();
# Line 1913 | Line 1920 | public class CompletableFutureTest exten
1920          assertTrue(snd.complete(w2));
1921          final CompletableFuture<Void> h3 = m.thenAcceptBoth(f, g, r3);
1922  
1923 <        checkCompletedWithWrappedCFException(h1);
1924 <        checkCompletedWithWrappedCFException(h2);
1925 <        checkCompletedWithWrappedCFException(h3);
1923 >        checkCompletedWithWrappedException(h1, r1.ex);
1924 >        checkCompletedWithWrappedException(h2, r2.ex);
1925 >        checkCompletedWithWrappedException(h3, r3.ex);
1926          r1.assertInvoked();
1927          r2.assertInvoked();
1928          r3.assertInvoked();
# Line 2077 | Line 2084 | public class CompletableFutureTest exten
2084          assertTrue(snd.complete(w2));
2085          final CompletableFuture<Void> h3 = m.runAfterBoth(f, g, r3);
2086  
2087 <        checkCompletedWithWrappedCFException(h1);
2088 <        checkCompletedWithWrappedCFException(h2);
2089 <        checkCompletedWithWrappedCFException(h3);
2087 >        checkCompletedWithWrappedException(h1, r1.ex);
2088 >        checkCompletedWithWrappedException(h2, r2.ex);
2089 >        checkCompletedWithWrappedException(h3, r3.ex);
2090          r1.assertInvoked();
2091          r2.assertInvoked();
2092          r3.assertInvoked();
# Line 2369 | Line 2376 | public class CompletableFutureTest exten
2376          f.complete(v1);
2377          final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]);
2378          final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]);
2379 <        checkCompletedWithWrappedCFException(h0);
2380 <        checkCompletedWithWrappedCFException(h1);
2381 <        checkCompletedWithWrappedCFException(h2);
2382 <        checkCompletedWithWrappedCFException(h3);
2379 >        checkCompletedWithWrappedException(h0, rs[0].ex);
2380 >        checkCompletedWithWrappedException(h1, rs[1].ex);
2381 >        checkCompletedWithWrappedException(h2, rs[2].ex);
2382 >        checkCompletedWithWrappedException(h3, rs[3].ex);
2383          for (int i = 0; i < 4; i++) rs[i].assertValue(v1);
2384  
2385          g.complete(v2);
# Line 2381 | Line 2388 | public class CompletableFutureTest exten
2388          final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]);
2389          final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]);
2390  
2391 <        checkCompletedWithWrappedCFException(h4);
2391 >        checkCompletedWithWrappedException(h4, rs[4].ex);
2392          assertTrue(Objects.equals(v1, rs[4].value) ||
2393                     Objects.equals(v2, rs[4].value));
2394 <        checkCompletedWithWrappedCFException(h5);
2394 >        checkCompletedWithWrappedException(h5, rs[5].ex);
2395          assertTrue(Objects.equals(v1, rs[5].value) ||
2396                     Objects.equals(v2, rs[5].value));
2397  
# Line 2628 | Line 2635 | public class CompletableFutureTest exten
2635          f.complete(v1);
2636          final CompletableFuture<Void> h2 = m.acceptEither(f, g, rs[2]);
2637          final CompletableFuture<Void> h3 = m.acceptEither(g, f, rs[3]);
2638 <        checkCompletedWithWrappedCFException(h0);
2639 <        checkCompletedWithWrappedCFException(h1);
2640 <        checkCompletedWithWrappedCFException(h2);
2641 <        checkCompletedWithWrappedCFException(h3);
2638 >        checkCompletedWithWrappedException(h0, rs[0].ex);
2639 >        checkCompletedWithWrappedException(h1, rs[1].ex);
2640 >        checkCompletedWithWrappedException(h2, rs[2].ex);
2641 >        checkCompletedWithWrappedException(h3, rs[3].ex);
2642          for (int i = 0; i < 4; i++) rs[i].assertValue(v1);
2643  
2644          g.complete(v2);
# Line 2640 | Line 2647 | public class CompletableFutureTest exten
2647          final CompletableFuture<Void> h4 = m.acceptEither(f, g, rs[4]);
2648          final CompletableFuture<Void> h5 = m.acceptEither(g, f, rs[5]);
2649  
2650 <        checkCompletedWithWrappedCFException(h4);
2650 >        checkCompletedWithWrappedException(h4, rs[4].ex);
2651          assertTrue(Objects.equals(v1, rs[4].value) ||
2652                     Objects.equals(v2, rs[4].value));
2653 <        checkCompletedWithWrappedCFException(h5);
2653 >        checkCompletedWithWrappedException(h5, rs[5].ex);
2654          assertTrue(Objects.equals(v1, rs[5].value) ||
2655                     Objects.equals(v2, rs[5].value));
2656  
# Line 2883 | Line 2890 | public class CompletableFutureTest exten
2890          assertTrue(f.complete(v1));
2891          final CompletableFuture<Void> h2 = m.runAfterEither(f, g, rs[2]);
2892          final CompletableFuture<Void> h3 = m.runAfterEither(g, f, rs[3]);
2893 <        checkCompletedWithWrappedCFException(h0);
2894 <        checkCompletedWithWrappedCFException(h1);
2895 <        checkCompletedWithWrappedCFException(h2);
2896 <        checkCompletedWithWrappedCFException(h3);
2893 >        checkCompletedWithWrappedException(h0, rs[0].ex);
2894 >        checkCompletedWithWrappedException(h1, rs[1].ex);
2895 >        checkCompletedWithWrappedException(h2, rs[2].ex);
2896 >        checkCompletedWithWrappedException(h3, rs[3].ex);
2897          for (int i = 0; i < 4; i++) rs[i].assertInvoked();
2898          assertTrue(g.complete(v2));
2899          final CompletableFuture<Void> h4 = m.runAfterEither(f, g, rs[4]);
2900          final CompletableFuture<Void> h5 = m.runAfterEither(g, f, rs[5]);
2901 <        checkCompletedWithWrappedCFException(h4);
2902 <        checkCompletedWithWrappedCFException(h5);
2901 >        checkCompletedWithWrappedException(h4, rs[4].ex);
2902 >        checkCompletedWithWrappedException(h5, rs[5].ex);
2903  
2904          checkCompletedNormally(f, v1);
2905          checkCompletedNormally(g, v2);
# Line 2953 | Line 2960 | public class CompletableFutureTest exten
2960          final CompletableFuture<Integer> g = m.thenCompose(f, r);
2961          if (createIncomplete) assertTrue(f.complete(v1));
2962  
2963 <        checkCompletedWithWrappedCFException(g);
2963 >        checkCompletedWithWrappedException(g, r.ex);
2964          checkCompletedNormally(f, v1);
2965      }}
2966  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines