3167 |
|
final CompletableFuture<Integer> g = m.exceptionallyCompose(f, r); |
3168 |
|
if (createIncomplete) assertTrue(f.complete(v1)); |
3169 |
|
|
3170 |
– |
if (!createIncomplete && testImplementationDetails) |
3171 |
– |
assertSame(f, g); |
3170 |
|
checkCompletedNormally(f, v1); |
3171 |
|
checkCompletedNormally(g, v1); |
3172 |
|
r.assertNotInvoked(); |
3214 |
|
r.assertInvoked(); |
3215 |
|
}} |
3216 |
|
|
3217 |
+ |
/** |
3218 |
+ |
* exceptionallyCompose result completes exceptionally if the |
3219 |
+ |
* result of the action does |
3220 |
+ |
*/ |
3221 |
+ |
public void testExceptionallyCompose_actionReturnsFailingFuture() { |
3222 |
+ |
for (ExecutionMode m : ExecutionMode.values()) |
3223 |
+ |
for (int order = 0; order < 6; order++) |
3224 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
3225 |
+ |
{ |
3226 |
+ |
final CFException ex0 = new CFException(); |
3227 |
+ |
final CFException ex = new CFException(); |
3228 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
3229 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
3230 |
+ |
final CompletableFuture<Integer> h; |
3231 |
+ |
// Test all permutations of orders |
3232 |
+ |
switch (order) { |
3233 |
+ |
case 0: |
3234 |
+ |
assertTrue(f.completeExceptionally(ex0)); |
3235 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3236 |
+ |
h = m.exceptionallyCompose(f, (x -> g)); |
3237 |
+ |
break; |
3238 |
+ |
case 1: |
3239 |
+ |
assertTrue(f.completeExceptionally(ex0)); |
3240 |
+ |
h = m.exceptionallyCompose(f, (x -> g)); |
3241 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3242 |
+ |
break; |
3243 |
+ |
case 2: |
3244 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3245 |
+ |
assertTrue(f.completeExceptionally(ex0)); |
3246 |
+ |
h = m.exceptionallyCompose(f, (x -> g)); |
3247 |
+ |
break; |
3248 |
+ |
case 3: |
3249 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3250 |
+ |
h = m.exceptionallyCompose(f, (x -> g)); |
3251 |
+ |
assertTrue(f.completeExceptionally(ex0)); |
3252 |
+ |
break; |
3253 |
+ |
case 4: |
3254 |
+ |
h = m.exceptionallyCompose(f, (x -> g)); |
3255 |
+ |
assertTrue(f.completeExceptionally(ex0)); |
3256 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3257 |
+ |
break; |
3258 |
+ |
case 5: |
3259 |
+ |
h = m.exceptionallyCompose(f, (x -> g)); |
3260 |
+ |
assertTrue(f.completeExceptionally(ex0)); |
3261 |
+ |
assertTrue(g.completeExceptionally(ex)); |
3262 |
+ |
break; |
3263 |
+ |
default: throw new AssertionError(); |
3264 |
+ |
} |
3265 |
+ |
|
3266 |
+ |
checkCompletedExceptionally(g, ex); |
3267 |
+ |
checkCompletedWithWrappedException(h, ex); |
3268 |
+ |
checkCompletedExceptionally(f, ex0); |
3269 |
+ |
}} |
3270 |
|
|
3271 |
|
// other static methods |
3272 |
|
|
4907 |
|
}} |
4908 |
|
|
4909 |
|
/** |
4910 |
< |
* default exceptionallyCompose result completes normally after normal |
4911 |
< |
* completion of source |
4910 |
> |
* default-implemented exceptionallyCompose result completes |
4911 |
> |
* normally after normal completion of source |
4912 |
|
*/ |
4913 |
|
public void testDefaultExceptionallyCompose_normalCompletion() { |
4914 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
4974 |
|
}} |
4975 |
|
|
4976 |
|
/** |
4977 |
< |
* default exceptionallyComposeAsync result completes normally after normal |
4978 |
< |
* completion of source |
4977 |
> |
* default-implemented exceptionallyComposeAsync result completes |
4978 |
> |
* normally after normal completion of source |
4979 |
|
*/ |
4980 |
|
public void testDefaultExceptionallyComposeAsync_normalCompletion() { |
4981 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
5040 |
|
r.assertInvoked(); |
5041 |
|
}} |
5042 |
|
|
4992 |
– |
|
5043 |
|
/** |
5044 |
< |
* default exceptionallyComposeAsync result completes normally after normal |
5045 |
< |
* completion of source |
5044 |
> |
* default-implemented exceptionallyComposeAsync result completes |
5045 |
> |
* normally after normal completion of source |
5046 |
|
*/ |
5047 |
|
public void testDefaultExceptionallyComposeAsyncExecutor_normalCompletion() { |
5048 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |