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.54 by jsr166, Mon Jun 2 21:32:24 2014 UTC vs.
Revision 1.56 by jsr166, Mon Jun 2 22:20:32 2014 UTC

# Line 284 | Line 284 | public class CompletableFutureTest exten
284      public void testGetNumberOfDependents() {
285          CompletableFuture<Integer> f = new CompletableFuture<>();
286          assertEquals(0, f.getNumberOfDependents());
287 <        CompletableFuture g = f.thenRun(new Noop());
287 >        CompletableFuture g = f.thenRun(new Noop(ExecutionMode.DEFAULT));
288          assertEquals(1, f.getNumberOfDependents());
289          assertEquals(0, g.getNumberOfDependents());
290 <        CompletableFuture h = f.thenRun(new Noop());
290 >        CompletableFuture h = f.thenRun(new Noop(ExecutionMode.DEFAULT));
291          assertEquals(2, f.getNumberOfDependents());
292          f.complete(1);
293          checkCompletedNormally(g, null);
# Line 349 | Line 349 | public class CompletableFutureTest exten
349          }
350      }
351      static final class IncFunction implements Function<Integer,Integer> {
352 +        final ExecutionMode m;
353          int invocationCount = 0;
354          Integer value;
355 +        IncFunction(ExecutionMode m) { this.m = m; }
356          public Integer apply(Integer x) {
357 +            m.checkExecutionMode();
358              invocationCount++;
359              return value = inc(x);
360          }
361      }
362      static final class SubtractAction implements BiConsumer<Integer, Integer> {
363 +        final ExecutionMode m;
364          int invocationCount = 0;
365          Integer value;
366          // Check this action was invoked exactly once when result is computed.
367 +        SubtractAction(ExecutionMode m) { this.m = m; }
368          public void accept(Integer x, Integer y) {
369 +            m.checkExecutionMode();
370              invocationCount++;
371              value = subtract(x, y);
372          }
373      }
374      static final class SubtractFunction implements BiFunction<Integer, Integer, Integer> {
375 +        final ExecutionMode m;
376          int invocationCount = 0;
377          Integer value;
378          // Check this action was invoked exactly once when result is computed.
379 +        SubtractFunction(ExecutionMode m) { this.m = m; }
380          public Integer apply(Integer x, Integer y) {
381 +            m.checkExecutionMode();
382              invocationCount++;
383              return value = subtract(x, y);
384          }
385      }
386      static final class Noop implements Runnable {
387 +        final ExecutionMode m;
388          int invocationCount = 0;
389 +        Noop(ExecutionMode m) { this.m = m; }
390          public void run() {
391 +            m.checkExecutionMode();
392              invocationCount++;
393          }
394      }
395  
396      static final class FailingSupplier implements Supplier<Integer> {
397 +        final ExecutionMode m;
398          int invocationCount = 0;
399 +        FailingSupplier(ExecutionMode m) { this.m = m; }
400          public Integer get() {
401 +            m.checkExecutionMode();
402              invocationCount++;
403              throw new CFException();
404          }
405      }
406      static final class FailingConsumer implements Consumer<Integer> {
407 +        final ExecutionMode m;
408          int invocationCount = 0;
409 +        FailingConsumer(ExecutionMode m) { this.m = m; }
410          public void accept(Integer x) {
411 +            m.checkExecutionMode();
412              invocationCount++;
413              throw new CFException();
414          }
415      }
416      static final class FailingBiConsumer implements BiConsumer<Integer, Integer> {
417 +        final ExecutionMode m;
418          int invocationCount = 0;
419 +        FailingBiConsumer(ExecutionMode m) { this.m = m; }
420          public void accept(Integer x, Integer y) {
421 +            m.checkExecutionMode();
422              invocationCount++;
423              throw new CFException();
424          }
425      }
426      static final class FailingFunction implements Function<Integer, Integer> {
427 +        final ExecutionMode m;
428          int invocationCount = 0;
429 +        FailingFunction(ExecutionMode m) { this.m = m; }
430          public Integer apply(Integer x) {
431 +            m.checkExecutionMode();
432              invocationCount++;
433              throw new CFException();
434          }
435      }
436      static final class FailingBiFunction implements BiFunction<Integer, Integer, Integer> {
437 +        final ExecutionMode m;
438          int invocationCount = 0;
439 +        FailingBiFunction(ExecutionMode m) { this.m = m; }
440          public Integer apply(Integer x, Integer y) {
441 +            m.checkExecutionMode();
442              invocationCount++;
443              throw new CFException();
444          }
445      }
446      static final class FailingRunnable implements Runnable {
447 +        final ExecutionMode m;
448          int invocationCount = 0;
449 +        FailingRunnable(ExecutionMode m) { this.m = m; }
450          public void run() {
451 +            m.checkExecutionMode();
452              invocationCount++;
453              throw new CFException();
454          }
# Line 426 | Line 456 | public class CompletableFutureTest exten
456  
457      static final class CompletableFutureInc
458          implements Function<Integer, CompletableFuture<Integer>> {
459 +        final ExecutionMode m;
460          int invocationCount = 0;
461 +        CompletableFutureInc(ExecutionMode m) { this.m = m; }
462          public CompletableFuture<Integer> apply(Integer x) {
463 +            m.checkExecutionMode();
464              invocationCount++;
465              CompletableFuture<Integer> f = new CompletableFuture<>();
466              f.complete(inc(x));
# Line 437 | Line 470 | public class CompletableFutureTest exten
470  
471      static final class FailingCompletableFutureFunction
472          implements Function<Integer, CompletableFuture<Integer>> {
473 +        final ExecutionMode m;
474          int invocationCount = 0;
475 +        FailingCompletableFutureFunction(ExecutionMode m) { this.m = m; }
476          public CompletableFuture<Integer> apply(Integer x) {
477 +            m.checkExecutionMode();
478              invocationCount++;
479              throw new CFException();
480          }
# Line 446 | Line 482 | public class CompletableFutureTest exten
482  
483      // Used for explicit executor tests
484      static final class ThreadExecutor implements Executor {
485 <        AtomicInteger count = new AtomicInteger(0);
485 >        final AtomicInteger count = new AtomicInteger(0);
486 >        static final ThreadGroup tg = new ThreadGroup("ThreadExecutor");
487 >        static boolean startedCurrentThread() {
488 >            return Thread.currentThread().getThreadGroup() == tg;
489 >        }
490  
491          public void execute(Runnable r) {
492              count.getAndIncrement();
493 <            new Thread(r).start();
493 >            new Thread(tg, r).start();
494          }
495      }
496  
# Line 596 | Line 636 | public class CompletableFutureTest exten
636  
637          EXECUTOR {
638              public void checkExecutionMode() {
639 <                //TODO
639 >                assertTrue(ThreadExecutor.startedCurrentThread());
640              }
641              public <T> CompletableFuture<Void> thenRun
642                  (CompletableFuture<T> f, Runnable a) {
# Line 909 | Line 949 | public class CompletableFutureTest exten
949       * runAsync completes after running Runnable
950       */
951      public void testRunAsync() {
952 <        Noop r = new Noop();
952 >        Noop r = new Noop(ExecutionMode.ASYNC);
953          CompletableFuture<Void> f = CompletableFuture.runAsync(r);
954          assertNull(f.join());
955          assertEquals(1, r.invocationCount);
# Line 920 | Line 960 | public class CompletableFutureTest exten
960       * runAsync with executor completes after running Runnable
961       */
962      public void testRunAsync2() {
963 <        Noop r = new Noop();
963 >        Noop r = new Noop(ExecutionMode.EXECUTOR);
964          ThreadExecutor exec = new ThreadExecutor();
965          CompletableFuture<Void> f = CompletableFuture.runAsync(r, exec);
966          assertNull(f.join());
# Line 933 | Line 973 | public class CompletableFutureTest exten
973       * failing runAsync completes exceptionally after running Runnable
974       */
975      public void testRunAsync3() {
976 <        FailingRunnable r = new FailingRunnable();
976 >        FailingRunnable r = new FailingRunnable(ExecutionMode.ASYNC);
977          CompletableFuture<Void> f = CompletableFuture.runAsync(r);
978          checkCompletedWithWrappedCFException(f);
979          assertEquals(1, r.invocationCount);
# Line 963 | Line 1003 | public class CompletableFutureTest exten
1003       * Failing supplyAsync completes exceptionally
1004       */
1005      public void testSupplyAsync3() {
1006 <        FailingSupplier r = new FailingSupplier();
1006 >        FailingSupplier r = new FailingSupplier(ExecutionMode.ASYNC);
1007          CompletableFuture<Integer> f = CompletableFuture.supplyAsync(r);
1008          checkCompletedWithWrappedCFException(f);
1009          assertEquals(1, r.invocationCount);
# Line 980 | Line 1020 | public class CompletableFutureTest exten
1020          for (Integer v1 : new Integer[] { 1, null })
1021      {
1022          final CompletableFuture<Integer> f = new CompletableFuture<>();
1023 <        final Noop r = new Noop();
1023 >        final Noop r = new Noop(m);
1024          if (!createIncomplete) f.complete(v1);
1025          final CompletableFuture<Void> g = m.thenRun(f, r);
1026          if (createIncomplete) {
# Line 1003 | Line 1043 | public class CompletableFutureTest exten
1043      {
1044          final CFException ex = new CFException();
1045          final CompletableFuture<Integer> f = new CompletableFuture<>();
1046 <        final Noop r = new Noop();
1046 >        final Noop r = new Noop(m);
1047          if (!createIncomplete) f.completeExceptionally(ex);
1048          final CompletableFuture<Void> g = m.thenRun(f, r);
1049          if (createIncomplete) {
# Line 1025 | Line 1065 | public class CompletableFutureTest exten
1065          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1066      {
1067          final CompletableFuture<Integer> f = new CompletableFuture<>();
1068 <        final Noop r = new Noop();
1068 >        final Noop r = new Noop(m);
1069          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1070 <        final CompletableFuture<Void> g = f.thenRun(r);
1070 >        final CompletableFuture<Void> g = m.thenRun(f, r);
1071          if (createIncomplete) {
1072              checkIncomplete(g);
1073              assertTrue(f.cancel(mayInterruptIfRunning));
# Line 1047 | Line 1087 | public class CompletableFutureTest exten
1087          for (Integer v1 : new Integer[] { 1, null })
1088      {
1089          final CompletableFuture<Integer> f = new CompletableFuture<>();
1090 <        final FailingRunnable r = new FailingRunnable();
1090 >        final FailingRunnable r = new FailingRunnable(m);
1091          if (!createIncomplete) f.complete(v1);
1092 <        final CompletableFuture<Void> g = f.thenRun(r);
1092 >        final CompletableFuture<Void> g = m.thenRun(f, r);
1093          if (createIncomplete) {
1094              checkIncomplete(g);
1095              f.complete(v1);
# Line 1068 | Line 1108 | public class CompletableFutureTest exten
1108          for (Integer v1 : new Integer[] { 1, null })
1109      {
1110          final CompletableFuture<Integer> f = new CompletableFuture<>();
1111 <        final IncFunction r = new IncFunction();
1111 >        final IncFunction r = new IncFunction(m);
1112          if (!createIncomplete) f.complete(v1);
1113          final CompletableFuture<Integer> g = m.thenApply(f, r);
1114          if (createIncomplete) {
# Line 1091 | Line 1131 | public class CompletableFutureTest exten
1131      {
1132          final CFException ex = new CFException();
1133          final CompletableFuture<Integer> f = new CompletableFuture<>();
1134 <        final IncFunction r = new IncFunction();
1134 >        final IncFunction r = new IncFunction(m);
1135          if (!createIncomplete) f.completeExceptionally(ex);
1136          final CompletableFuture<Integer> g = m.thenApply(f, r);
1137          if (createIncomplete) {
# Line 1113 | Line 1153 | public class CompletableFutureTest exten
1153          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
1154      {
1155          final CompletableFuture<Integer> f = new CompletableFuture<>();
1156 <        final IncFunction r = new IncFunction();
1156 >        final IncFunction r = new IncFunction(m);
1157          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1158 <        final CompletableFuture<Integer> g = f.thenApply(r);
1158 >        final CompletableFuture<Integer> g = m.thenApply(f, r);
1159          if (createIncomplete) {
1160              checkIncomplete(g);
1161              assertTrue(f.cancel(mayInterruptIfRunning));
# Line 1135 | Line 1175 | public class CompletableFutureTest exten
1175          for (Integer v1 : new Integer[] { 1, null })
1176      {
1177          final CompletableFuture<Integer> f = new CompletableFuture<>();
1178 <        final FailingFunction r = new FailingFunction();
1178 >        final FailingFunction r = new FailingFunction(m);
1179          if (!createIncomplete) f.complete(v1);
1180 <        final CompletableFuture<Integer> g = f.thenApply(r);
1180 >        final CompletableFuture<Integer> g = m.thenApply(f, r);
1181          if (createIncomplete) {
1182              checkIncomplete(g);
1183              f.complete(v1);
# Line 1202 | Line 1242 | public class CompletableFutureTest exten
1242          for (Integer v1 : new Integer[] { 1, null })
1243      {
1244          final CompletableFuture<Integer> f = new CompletableFuture<>();
1245 <        final FailingConsumer r = new FailingConsumer();
1245 >        final FailingConsumer r = new FailingConsumer(m);
1246          if (!createIncomplete) f.complete(v1);
1247 <        final CompletableFuture<Void> g = f.thenAccept(r);
1247 >        final CompletableFuture<Void> g = m.thenAccept(f, r);
1248          if (createIncomplete) {
1249              checkIncomplete(g);
1250              f.complete(v1);
# Line 1225 | Line 1265 | public class CompletableFutureTest exten
1265          final CompletableFuture<Integer> f = new CompletableFuture<>();
1266          final IncAction r = new IncAction();
1267          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
1268 <        final CompletableFuture<Void> g = f.thenAccept(r);
1268 >        final CompletableFuture<Void> g = m.thenAccept(f, r);
1269          if (createIncomplete) {
1270              checkIncomplete(g);
1271              assertTrue(f.cancel(mayInterruptIfRunning));
# Line 1249 | Line 1289 | public class CompletableFutureTest exten
1289      {
1290          final CompletableFuture<Integer> f = new CompletableFuture<>();
1291          final CompletableFuture<Integer> g = new CompletableFuture<>();
1292 <        final SubtractFunction r = new SubtractFunction();
1292 >        final SubtractFunction r = new SubtractFunction(m);
1293  
1294          if (fFirst) f.complete(v1); else g.complete(v2);
1295          if (!createIncomplete)
# Line 1280 | Line 1320 | public class CompletableFutureTest exten
1320          final CompletableFuture<Integer> f = new CompletableFuture<>();
1321          final CompletableFuture<Integer> g = new CompletableFuture<>();
1322          final CFException ex = new CFException();
1323 <        final SubtractFunction r = new SubtractFunction();
1323 >        final SubtractFunction r = new SubtractFunction(m);
1324  
1325          (fFirst ? f : g).complete(v1);
1326          if (!createIncomplete)
# Line 1308 | Line 1348 | public class CompletableFutureTest exten
1348      {
1349          final CompletableFuture<Integer> f = new CompletableFuture<>();
1350          final CompletableFuture<Integer> g = new CompletableFuture<>();
1351 <        final FailingBiFunction r = new FailingBiFunction();
1351 >        final FailingBiFunction r = new FailingBiFunction(m);
1352          final CompletableFuture<Integer> h = m.thenCombine(f, g, r);
1353  
1354          if (fFirst) {
# Line 1336 | Line 1376 | public class CompletableFutureTest exten
1376      {
1377          final CompletableFuture<Integer> f = new CompletableFuture<>();
1378          final CompletableFuture<Integer> g = new CompletableFuture<>();
1379 <        final SubtractFunction r = new SubtractFunction();
1379 >        final SubtractFunction r = new SubtractFunction(m);
1380  
1381          (fFirst ? f : g).complete(v1);
1382          if (!createIncomplete)
# Line 1366 | Line 1406 | public class CompletableFutureTest exten
1406      {
1407          final CompletableFuture<Integer> f = new CompletableFuture<>();
1408          final CompletableFuture<Integer> g = new CompletableFuture<>();
1409 <        final SubtractAction r = new SubtractAction();
1409 >        final SubtractAction r = new SubtractAction(m);
1410  
1411          if (fFirst) f.complete(v1); else g.complete(v2);
1412          if (!createIncomplete)
# Line 1397 | Line 1437 | public class CompletableFutureTest exten
1437          final CompletableFuture<Integer> f = new CompletableFuture<>();
1438          final CompletableFuture<Integer> g = new CompletableFuture<>();
1439          final CFException ex = new CFException();
1440 <        final SubtractAction r = new SubtractAction();
1440 >        final SubtractAction r = new SubtractAction(m);
1441  
1442          (fFirst ? f : g).complete(v1);
1443          if (!createIncomplete)
# Line 1425 | Line 1465 | public class CompletableFutureTest exten
1465      {
1466          final CompletableFuture<Integer> f = new CompletableFuture<>();
1467          final CompletableFuture<Integer> g = new CompletableFuture<>();
1468 <        final FailingBiConsumer r = new FailingBiConsumer();
1468 >        final FailingBiConsumer r = new FailingBiConsumer(m);
1469          final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r);
1470  
1471          if (fFirst) {
# Line 1453 | Line 1493 | public class CompletableFutureTest exten
1493      {
1494          final CompletableFuture<Integer> f = new CompletableFuture<>();
1495          final CompletableFuture<Integer> g = new CompletableFuture<>();
1496 <        final SubtractAction r = new SubtractAction();
1496 >        final SubtractAction r = new SubtractAction(m);
1497  
1498          (fFirst ? f : g).complete(v1);
1499          if (!createIncomplete)
# Line 1483 | Line 1523 | public class CompletableFutureTest exten
1523      {
1524          final CompletableFuture<Integer> f = new CompletableFuture<>();
1525          final CompletableFuture<Integer> g = new CompletableFuture<>();
1526 <        final Noop r = new Noop();
1526 >        final Noop r = new Noop(m);
1527  
1528          if (fFirst) f.complete(v1); else g.complete(v2);
1529          if (!createIncomplete)
# Line 1514 | Line 1554 | public class CompletableFutureTest exten
1554          final CompletableFuture<Integer> f = new CompletableFuture<>();
1555          final CompletableFuture<Integer> g = new CompletableFuture<>();
1556          final CFException ex = new CFException();
1557 <        final Noop r = new Noop();
1557 >        final Noop r = new Noop(m);
1558  
1559          (fFirst ? f : g).complete(v1);
1560          if (!createIncomplete)
# Line 1542 | Line 1582 | public class CompletableFutureTest exten
1582      {
1583          final CompletableFuture<Integer> f = new CompletableFuture<>();
1584          final CompletableFuture<Integer> g = new CompletableFuture<>();
1585 <        final FailingRunnable r = new FailingRunnable();
1585 >        final FailingRunnable r = new FailingRunnable(m);
1586  
1587          CompletableFuture<Void> h1 = m.runAfterBoth(f, g, r);
1588          if (fFirst) {
# Line 1572 | Line 1612 | public class CompletableFutureTest exten
1612      {
1613          final CompletableFuture<Integer> f = new CompletableFuture<>();
1614          final CompletableFuture<Integer> g = new CompletableFuture<>();
1615 <        final Noop r = new Noop();
1615 >        final Noop r = new Noop(m);
1616  
1617  
1618          (fFirst ? f : g).complete(v1);
# Line 1603 | Line 1643 | public class CompletableFutureTest exten
1643      {
1644          final CompletableFuture<Integer> f = new CompletableFuture<>();
1645          final CompletableFuture<Integer> g = new CompletableFuture<>();
1646 <        final IncFunction r = new IncFunction();
1646 >        final IncFunction r = new IncFunction(m);
1647  
1648          if (!createIncomplete)
1649              if (fFirst) f.complete(v1); else g.complete(v2);
# Line 1629 | Line 1669 | public class CompletableFutureTest exten
1669      {
1670          final CompletableFuture<Integer> f = new CompletableFuture<>();
1671          final CompletableFuture<Integer> g = new CompletableFuture<>();
1672 <        final IncFunction r = new IncFunction();
1672 >        final IncFunction r = new IncFunction(m);
1673  
1674          if (fFirst) {
1675              f.complete(v1);
# Line 1663 | Line 1703 | public class CompletableFutureTest exten
1703          final CompletableFuture<Integer> f = new CompletableFuture<>();
1704          final CompletableFuture<Integer> g = new CompletableFuture<>();
1705          final CFException ex = new CFException();
1706 <        final IncFunction r = new IncFunction();
1706 >        final IncFunction r = new IncFunction(m);
1707  
1708          if (!createIncomplete) (fFirst ? f : g).completeExceptionally(ex);
1709          final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
# Line 1690 | Line 1730 | public class CompletableFutureTest exten
1730      {
1731          final CompletableFuture<Integer> f = new CompletableFuture<>();
1732          final CompletableFuture<Integer> g = new CompletableFuture<>();
1733 <        final IncFunction r1 = new IncFunction();
1734 <        final IncFunction r2 = new IncFunction();
1733 >        final IncFunction r1 = new IncFunction(m);
1734 >        final IncFunction r2 = new IncFunction(m);
1735          final CFException ex = new CFException();
1736          final CompletableFuture<Integer> j = (reverseArgs ? g : f);
1737          final CompletableFuture<Integer> k = (reverseArgs ? f : g);
# Line 1736 | Line 1776 | public class CompletableFutureTest exten
1776      {
1777          final CompletableFuture<Integer> f = new CompletableFuture<>();
1778          final CompletableFuture<Integer> g = new CompletableFuture<>();
1779 <        final FailingFunction r = new FailingFunction();
1779 >        final FailingFunction r = new FailingFunction(m);
1780          final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
1781  
1782          f.complete(v1);
# Line 1753 | Line 1793 | public class CompletableFutureTest exten
1793      {
1794          final CompletableFuture<Integer> f = new CompletableFuture<>();
1795          final CompletableFuture<Integer> g = new CompletableFuture<>();
1796 <        final FailingFunction r = new FailingFunction();
1796 >        final FailingFunction r = new FailingFunction(m);
1797          final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
1798  
1799          g.complete(v2);
# Line 1775 | Line 1815 | public class CompletableFutureTest exten
1815      {
1816          final CompletableFuture<Integer> f = new CompletableFuture<>();
1817          final CompletableFuture<Integer> g = new CompletableFuture<>();
1818 <        final IncFunction r = new IncFunction();
1818 >        final IncFunction r = new IncFunction(m);
1819  
1820          if (!createIncomplete) assertTrue((fFirst ? f : g).cancel(mayInterruptIfRunning));
1821          final CompletableFuture<Integer> h = m.applyToEither(f, g, r);
# Line 1803 | Line 1843 | public class CompletableFutureTest exten
1843      {
1844          final CompletableFuture<Integer> f = new CompletableFuture<>();
1845          final CompletableFuture<Integer> g = new CompletableFuture<>();
1846 <        final IncFunction r1 = new IncFunction();
1847 <        final IncFunction r2 = new IncFunction();
1846 >        final IncFunction r1 = new IncFunction(m);
1847 >        final IncFunction r2 = new IncFunction(m);
1848          final CFException ex = new CFException();
1849          final CompletableFuture<Integer> j = (reverseArgs ? g : f);
1850          final CompletableFuture<Integer> k = (reverseArgs ? f : g);
# Line 2016 | Line 2056 | public class CompletableFutureTest exten
2056      {
2057          final CompletableFuture<Integer> f = new CompletableFuture<>();
2058          final CompletableFuture<Integer> g = new CompletableFuture<>();
2059 <        final FailingConsumer r = new FailingConsumer();
2059 >        final FailingConsumer r = new FailingConsumer(m);
2060          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
2061  
2062          f.complete(v1);
# Line 2033 | Line 2073 | public class CompletableFutureTest exten
2073      {
2074          final CompletableFuture<Integer> f = new CompletableFuture<>();
2075          final CompletableFuture<Integer> g = new CompletableFuture<>();
2076 <        final FailingConsumer r = new FailingConsumer();
2076 >        final FailingConsumer r = new FailingConsumer(m);
2077          final CompletableFuture<Void> h = m.acceptEither(f, g, r);
2078  
2079          g.complete(v2);
# Line 2153 | Line 2193 | public class CompletableFutureTest exten
2193      {
2194          final CompletableFuture<Integer> f = new CompletableFuture<>();
2195          final CompletableFuture<Integer> g = new CompletableFuture<>();
2196 <        final Noop r = new Noop();
2196 >        final Noop r = new Noop(m);
2197          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2198  
2199          f.complete(v1);
# Line 2174 | Line 2214 | public class CompletableFutureTest exten
2214      {
2215          final CompletableFuture<Integer> f = new CompletableFuture<>();
2216          final CompletableFuture<Integer> g = new CompletableFuture<>();
2217 <        final Noop r = new Noop();
2217 >        final Noop r = new Noop(m);
2218          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2219  
2220          g.complete(v2);
# Line 2195 | Line 2235 | public class CompletableFutureTest exten
2235      {
2236          final CompletableFuture<Integer> f = new CompletableFuture<>();
2237          final CompletableFuture<Integer> g = new CompletableFuture<>();
2238 <        final Noop r = new Noop();
2238 >        final Noop r = new Noop(m);
2239  
2240          f.complete(v1);
2241          g.complete(v2);
# Line 2217 | Line 2257 | public class CompletableFutureTest exten
2257      {
2258          final CompletableFuture<Integer> f = new CompletableFuture<>();
2259          final CompletableFuture<Integer> g = new CompletableFuture<>();
2260 <        final Noop r = new Noop();
2260 >        final Noop r = new Noop(m);
2261          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2262          final CFException ex = new CFException();
2263  
# Line 2237 | Line 2277 | public class CompletableFutureTest exten
2277      {
2278          final CompletableFuture<Integer> f = new CompletableFuture<>();
2279          final CompletableFuture<Integer> g = new CompletableFuture<>();
2280 <        final Noop r = new Noop();
2280 >        final Noop r = new Noop(m);
2281          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2282          final CFException ex = new CFException();
2283  
# Line 2257 | Line 2297 | public class CompletableFutureTest exten
2297      {
2298          final CompletableFuture<Integer> f = new CompletableFuture<>();
2299          final CompletableFuture<Integer> g = new CompletableFuture<>();
2300 <        final Noop r = new Noop();
2300 >        final Noop r = new Noop(m);
2301          final CFException ex = new CFException();
2302  
2303          g.completeExceptionally(ex);
# Line 2284 | Line 2324 | public class CompletableFutureTest exten
2324      {
2325          final CompletableFuture<Integer> f = new CompletableFuture<>();
2326          final CompletableFuture<Integer> g = new CompletableFuture<>();
2327 <        final Noop r = new Noop();
2327 >        final Noop r = new Noop(m);
2328          final CFException ex = new CFException();
2329  
2330          f.completeExceptionally(ex);
# Line 2315 | Line 2355 | public class CompletableFutureTest exten
2355      {
2356          final CompletableFuture<Integer> f = new CompletableFuture<>();
2357          final CompletableFuture<Integer> g = new CompletableFuture<>();
2358 <        final FailingRunnable r = new FailingRunnable();
2358 >        final FailingRunnable r = new FailingRunnable(m);
2359          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2360  
2361          f.complete(v1);
# Line 2332 | Line 2372 | public class CompletableFutureTest exten
2372      {
2373          final CompletableFuture<Integer> f = new CompletableFuture<>();
2374          final CompletableFuture<Integer> g = new CompletableFuture<>();
2375 <        final FailingRunnable r = new FailingRunnable();
2375 >        final FailingRunnable r = new FailingRunnable(m);
2376          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2377  
2378          g.complete(v2);
# Line 2352 | Line 2392 | public class CompletableFutureTest exten
2392      {
2393          final CompletableFuture<Integer> f = new CompletableFuture<>();
2394          final CompletableFuture<Integer> g = new CompletableFuture<>();
2395 <        final Noop r = new Noop();
2395 >        final Noop r = new Noop(m);
2396          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2397  
2398          assertTrue(f.cancel(mayInterruptIfRunning));
# Line 2372 | Line 2412 | public class CompletableFutureTest exten
2412      {
2413          final CompletableFuture<Integer> f = new CompletableFuture<>();
2414          final CompletableFuture<Integer> g = new CompletableFuture<>();
2415 <        final Noop r = new Noop();
2415 >        final Noop r = new Noop(m);
2416          final CompletableFuture<Void> h = m.runAfterEither(f, g, r);
2417  
2418          assertTrue(g.cancel(mayInterruptIfRunning));
# Line 2392 | Line 2432 | public class CompletableFutureTest exten
2432      {
2433          final CompletableFuture<Integer> f = new CompletableFuture<>();
2434          final CompletableFuture<Integer> g = new CompletableFuture<>();
2435 <        final Noop r = new Noop();
2435 >        final Noop r = new Noop(m);
2436  
2437          assertTrue(g.cancel(mayInterruptIfRunning));
2438          f.complete(v1);
# Line 2419 | Line 2459 | public class CompletableFutureTest exten
2459      {
2460          final CompletableFuture<Integer> f = new CompletableFuture<>();
2461          final CompletableFuture<Integer> g = new CompletableFuture<>();
2462 <        final Noop r = new Noop();
2462 >        final Noop r = new Noop(m);
2463  
2464          assertTrue(f.cancel(mayInterruptIfRunning));
2465          g.complete(v1);
# Line 2448 | Line 2488 | public class CompletableFutureTest exten
2488          for (Integer v1 : new Integer[] { 1, null })
2489      {
2490          final CompletableFuture<Integer> f = new CompletableFuture<>();
2491 <        final CompletableFutureInc r = new CompletableFutureInc();
2491 >        final CompletableFutureInc r = new CompletableFutureInc(m);
2492          if (!createIncomplete) f.complete(v1);
2493 <        final CompletableFuture<Integer> g = f.thenCompose(r);
2493 >        final CompletableFuture<Integer> g = m.thenCompose(f, r);
2494          if (createIncomplete) f.complete(v1);
2495  
2496          checkCompletedNormally(g, inc(v1));
# Line 2467 | Line 2507 | public class CompletableFutureTest exten
2507          for (boolean createIncomplete : new boolean[] { true, false })
2508      {
2509          final CFException ex = new CFException();
2510 <        final CompletableFutureInc r = new CompletableFutureInc();
2510 >        final CompletableFutureInc r = new CompletableFutureInc(m);
2511          final CompletableFuture<Integer> f = new CompletableFuture<>();
2512          if (!createIncomplete) f.completeExceptionally(ex);
2513 <        final CompletableFuture<Integer> g = f.thenCompose(r);
2513 >        final CompletableFuture<Integer> g = m.thenCompose(f, r);
2514          if (createIncomplete) f.completeExceptionally(ex);
2515  
2516          checkCompletedWithWrappedCFException(g, ex);
# Line 2488 | Line 2528 | public class CompletableFutureTest exten
2528      {
2529          final CompletableFuture<Integer> f = new CompletableFuture<>();
2530          final FailingCompletableFutureFunction r
2531 <            = new FailingCompletableFutureFunction();
2531 >            = new FailingCompletableFutureFunction(m);
2532          if (!createIncomplete) f.complete(v1);
2533 <        final CompletableFuture<Integer> g = f.thenCompose(r);
2533 >        final CompletableFuture<Integer> g = m.thenCompose(f, r);
2534          if (createIncomplete) f.complete(v1);
2535  
2536          checkCompletedWithWrappedCFException(g);
# Line 2506 | Line 2546 | public class CompletableFutureTest exten
2546          for (boolean mayInterruptIfRunning : new boolean[] { true, false })
2547      {
2548          final CompletableFuture<Integer> f = new CompletableFuture<>();
2549 <        final CompletableFutureInc r = new CompletableFutureInc();
2549 >        final CompletableFutureInc r = new CompletableFutureInc(m);
2550          if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning));
2551 <        final CompletableFuture<Integer> g = f.thenCompose(r);
2551 >        final CompletableFuture<Integer> g = m.thenCompose(f, r);
2552          if (createIncomplete) {
2553              checkIncomplete(g);
2554              assertTrue(f.cancel(mayInterruptIfRunning));
# Line 2680 | Line 2720 | public class CompletableFutureTest exten
2720  
2721              () -> f.thenCompose(null),
2722              () -> f.thenComposeAsync(null),
2723 <            () -> f.thenComposeAsync(new CompletableFutureInc(), null),
2723 >            () -> f.thenComposeAsync(new CompletableFutureInc(ExecutionMode.EXECUTOR), null),
2724              () -> f.thenComposeAsync(null, exec),
2725  
2726              () -> f.exceptionally(null),

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines