--- jsr166/src/test/tck/CompletableFutureTest.java 2013/04/08 16:45:15 1.20 +++ jsr166/src/test/tck/CompletableFutureTest.java 2013/04/08 16:58:17 1.21 @@ -1127,11 +1127,20 @@ public class CompletableFutureTest exten * thenCompose result completes normally after normal completion of source */ public void testThenCompose() { - CompletableFuture f = new CompletableFuture(); - CompletableFutureInc r = new CompletableFutureInc(); - CompletableFuture g = f.thenCompose(r); + CompletableFuture f, g; + CompletableFutureInc r; + + f = new CompletableFuture(); + g = f.thenCompose(r = new CompletableFutureInc()); + f.complete(one); + checkCompletedNormally(g, two); + assertTrue(r.ran); + + f = new CompletableFuture(); f.complete(one); + g = f.thenCompose(r = new CompletableFutureInc()); checkCompletedNormally(g, two); + assertTrue(r.ran); } /** @@ -1139,10 +1148,17 @@ public class CompletableFutureTest exten * completion of source */ public void testThenCompose2() { - CompletableFuture f = new CompletableFuture(); - CompletableFutureInc r = new CompletableFutureInc(); - CompletableFuture g = f.thenCompose(r); + CompletableFuture f, g; + CompletableFutureInc r; + + f = new CompletableFuture(); + g = f.thenCompose(r = new CompletableFutureInc()); + f.completeExceptionally(new CFException()); + checkCompletedWithWrappedCFException(g); + + f = new CompletableFuture(); f.completeExceptionally(new CFException()); + g = f.thenCompose(r = new CompletableFutureInc()); checkCompletedWithWrappedCFException(g); } @@ -1150,21 +1166,35 @@ public class CompletableFutureTest exten * thenCompose result completes exceptionally if action does */ public void testThenCompose3() { - CompletableFuture f = new CompletableFuture(); - FailingCompletableFutureFunction r = new FailingCompletableFutureFunction(); - CompletableFuture g = f.thenCompose(r); + CompletableFuture f, g; + FailingCompletableFutureFunction r; + + f = new CompletableFuture(); + g = f.thenCompose(r = new FailingCompletableFutureFunction()); f.complete(one); checkCompletedWithWrappedCFException(g); + + f = new CompletableFuture(); + f.complete(one); + g = f.thenCompose(r = new FailingCompletableFutureFunction()); + checkCompletedWithWrappedCFException(g); } /** * thenCompose result completes exceptionally if source cancelled */ public void testThenCompose4() { - CompletableFuture f = new CompletableFuture(); - CompletableFutureInc r = new CompletableFutureInc(); - CompletableFuture g = f.thenCompose(r); + CompletableFuture f, g; + CompletableFutureInc r; + + f = new CompletableFuture(); + g = f.thenCompose(r = new CompletableFutureInc()); + assertTrue(f.cancel(true)); + checkCompletedWithWrappedCancellationException(g); + + f = new CompletableFuture(); assertTrue(f.cancel(true)); + g = f.thenCompose(r = new CompletableFutureInc()); checkCompletedWithWrappedCancellationException(g); } @@ -1840,12 +1870,12 @@ public class CompletableFutureTest exten public void testThenComposeAsync3() { CompletableFuture f, g; FailingCompletableFutureFunction r; - + f = new CompletableFuture(); g = f.thenComposeAsync(r = new FailingCompletableFutureFunction()); f.complete(one); checkCompletedWithWrappedCFException(g); - + f = new CompletableFuture(); f.complete(one); g = f.thenComposeAsync(r = new FailingCompletableFutureFunction());