2994 |
|
checkCancelled(f); |
2995 |
|
}} |
2996 |
|
|
2997 |
+ |
/** |
2998 |
+ |
* thenCompose result completes exceptionally if the result of the action does |
2999 |
+ |
*/ |
3000 |
+ |
public void testThenCompose_actionReturnsFailingFuture() { |
3001 |
+ |
for (ExecutionMode m : ExecutionMode.values()) |
3002 |
+ |
for (int order = 0; order < 6; order++) |
3003 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
3004 |
+ |
{ |
3005 |
+ |
final CFException ex = new CFException(); |
3006 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
3007 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
3008 |
+ |
final CompletableFuture<Integer> h; |
3009 |
+ |
// Test all permutations of orders |
3010 |
+ |
switch (order) { |
3011 |
+ |
case 0: |
3012 |
+ |
assertTrue(f.complete(v1)); |
3013 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3014 |
+ |
h = m.thenCompose(f, (x -> g)); |
3015 |
+ |
break; |
3016 |
+ |
case 1: |
3017 |
+ |
assertTrue(f.complete(v1)); |
3018 |
+ |
h = m.thenCompose(f, (x -> g)); |
3019 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3020 |
+ |
break; |
3021 |
+ |
case 2: |
3022 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3023 |
+ |
assertTrue(f.complete(v1)); |
3024 |
+ |
h = m.thenCompose(f, (x -> g)); |
3025 |
+ |
break; |
3026 |
+ |
case 3: |
3027 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3028 |
+ |
h = m.thenCompose(f, (x -> g)); |
3029 |
+ |
assertTrue(f.complete(v1)); |
3030 |
+ |
break; |
3031 |
+ |
case 4: |
3032 |
+ |
h = m.thenCompose(f, (x -> g)); |
3033 |
+ |
assertTrue(f.complete(v1)); |
3034 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3035 |
+ |
break; |
3036 |
+ |
case 5: |
3037 |
+ |
h = m.thenCompose(f, (x -> g)); |
3038 |
+ |
assertTrue(f.complete(v1)); |
3039 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3040 |
+ |
break; |
3041 |
+ |
default: throw new AssertionError(); |
3042 |
+ |
} |
3043 |
+ |
|
3044 |
+ |
checkCompletedExceptionally(g, ex); |
3045 |
+ |
checkCompletedWithWrappedException(h, ex); |
3046 |
+ |
checkCompletedNormally(f, v1); |
3047 |
+ |
}} |
3048 |
+ |
|
3049 |
|
// other static methods |
3050 |
|
|
3051 |
|
/** |