320 |
|
checkCompletedNormally(f, "test"); |
321 |
|
} |
322 |
|
|
323 |
< |
static final class IntegerSupplier implements Supplier<Integer> { |
324 |
< |
final ExecutionMode m; |
323 |
> |
abstract class CheckedAction { |
324 |
|
int invocationCount = 0; |
325 |
+ |
final ExecutionMode m; |
326 |
+ |
CheckedAction(ExecutionMode m) { this.m = m; } |
327 |
+ |
void invoked() { |
328 |
+ |
m.checkExecutionMode(); |
329 |
+ |
assertEquals(0, invocationCount++); |
330 |
+ |
} |
331 |
+ |
void assertNotInvoked() { assertEquals(0, invocationCount); } |
332 |
+ |
void assertInvoked() { assertEquals(1, invocationCount); } |
333 |
+ |
} |
334 |
+ |
|
335 |
+ |
abstract class CheckedIntegerAction extends CheckedAction { |
336 |
+ |
Integer value; |
337 |
+ |
CheckedIntegerAction(ExecutionMode m) { super(m); } |
338 |
+ |
void assertValue(Integer expected) { |
339 |
+ |
assertInvoked(); |
340 |
+ |
assertEquals(expected, value); |
341 |
+ |
} |
342 |
+ |
} |
343 |
+ |
|
344 |
+ |
class IntegerSupplier extends CheckedAction |
345 |
+ |
implements Supplier<Integer> |
346 |
+ |
{ |
347 |
|
final Integer value; |
348 |
|
IntegerSupplier(ExecutionMode m, Integer value) { |
349 |
< |
this.m = m; |
349 |
> |
super(m); |
350 |
|
this.value = value; |
351 |
|
} |
352 |
|
public Integer get() { |
353 |
< |
m.checkExecutionMode(); |
333 |
< |
invocationCount++; |
353 |
> |
invoked(); |
354 |
|
return value; |
355 |
|
} |
356 |
|
} |
360 |
|
return (x == null) ? null : x + 1; |
361 |
|
} |
362 |
|
|
363 |
< |
static final class IncAction implements Consumer<Integer> { |
364 |
< |
int invocationCount = 0; |
365 |
< |
Integer value; |
363 |
> |
class IncAction extends CheckedIntegerAction |
364 |
> |
implements Consumer<Integer> |
365 |
> |
{ |
366 |
> |
IncAction(ExecutionMode m) { super(m); } |
367 |
|
public void accept(Integer x) { |
368 |
< |
invocationCount++; |
368 |
> |
invoked(); |
369 |
|
value = inc(x); |
370 |
|
} |
371 |
|
} |
372 |
< |
static final class IncFunction implements Function<Integer,Integer> { |
373 |
< |
final ExecutionMode m; |
374 |
< |
int invocationCount = 0; |
375 |
< |
Integer value; |
376 |
< |
IncFunction(ExecutionMode m) { this.m = m; } |
372 |
> |
|
373 |
> |
class IncFunction extends CheckedIntegerAction |
374 |
> |
implements Function<Integer,Integer> |
375 |
> |
{ |
376 |
> |
IncFunction(ExecutionMode m) { super(m); } |
377 |
|
public Integer apply(Integer x) { |
378 |
< |
m.checkExecutionMode(); |
358 |
< |
invocationCount++; |
378 |
> |
invoked(); |
379 |
|
return value = inc(x); |
380 |
|
} |
381 |
|
} |
388 |
|
- ((y == null) ? 99 : y.intValue()); |
389 |
|
} |
390 |
|
|
391 |
< |
static final class SubtractAction implements BiConsumer<Integer, Integer> { |
392 |
< |
final ExecutionMode m; |
393 |
< |
int invocationCount = 0; |
394 |
< |
Integer value; |
375 |
< |
// Check this action was invoked exactly once when result is computed. |
376 |
< |
SubtractAction(ExecutionMode m) { this.m = m; } |
391 |
> |
class SubtractAction extends CheckedIntegerAction |
392 |
> |
implements BiConsumer<Integer, Integer> |
393 |
> |
{ |
394 |
> |
SubtractAction(ExecutionMode m) { super(m); } |
395 |
|
public void accept(Integer x, Integer y) { |
396 |
< |
m.checkExecutionMode(); |
379 |
< |
invocationCount++; |
396 |
> |
invoked(); |
397 |
|
value = subtract(x, y); |
398 |
|
} |
399 |
|
} |
400 |
< |
static final class SubtractFunction implements BiFunction<Integer, Integer, Integer> { |
401 |
< |
final ExecutionMode m; |
402 |
< |
int invocationCount = 0; |
403 |
< |
Integer value; |
404 |
< |
// Check this action was invoked exactly once when result is computed. |
388 |
< |
SubtractFunction(ExecutionMode m) { this.m = m; } |
400 |
> |
|
401 |
> |
class SubtractFunction extends CheckedIntegerAction |
402 |
> |
implements BiFunction<Integer, Integer, Integer> |
403 |
> |
{ |
404 |
> |
SubtractFunction(ExecutionMode m) { super(m); } |
405 |
|
public Integer apply(Integer x, Integer y) { |
406 |
< |
m.checkExecutionMode(); |
391 |
< |
invocationCount++; |
406 |
> |
invoked(); |
407 |
|
return value = subtract(x, y); |
408 |
|
} |
409 |
|
} |
410 |
|
|
411 |
< |
static final class Noop implements Runnable { |
412 |
< |
final ExecutionMode m; |
398 |
< |
int invocationCount = 0; |
399 |
< |
Noop(ExecutionMode m) { this.m = m; } |
411 |
> |
class Noop extends CheckedAction implements Runnable { |
412 |
> |
Noop(ExecutionMode m) { super(m); } |
413 |
|
public void run() { |
414 |
< |
m.checkExecutionMode(); |
402 |
< |
invocationCount++; |
414 |
> |
invoked(); |
415 |
|
} |
416 |
|
} |
417 |
|
|
418 |
< |
static final class FailingSupplier implements Supplier<Integer> { |
419 |
< |
final ExecutionMode m; |
420 |
< |
int invocationCount = 0; |
409 |
< |
FailingSupplier(ExecutionMode m) { this.m = m; } |
418 |
> |
class FailingSupplier extends CheckedAction implements Supplier<Integer> |
419 |
> |
{ |
420 |
> |
FailingSupplier(ExecutionMode m) { super(m); } |
421 |
|
public Integer get() { |
422 |
< |
m.checkExecutionMode(); |
412 |
< |
invocationCount++; |
422 |
> |
invoked(); |
423 |
|
throw new CFException(); |
424 |
|
} |
425 |
|
} |
426 |
< |
static final class FailingConsumer implements Consumer<Integer> { |
427 |
< |
final ExecutionMode m; |
428 |
< |
int invocationCount = 0; |
419 |
< |
FailingConsumer(ExecutionMode m) { this.m = m; } |
426 |
> |
|
427 |
> |
class FailingConsumer extends CheckedAction implements Consumer<Integer> { |
428 |
> |
FailingConsumer(ExecutionMode m) { super(m); } |
429 |
|
public void accept(Integer x) { |
430 |
< |
m.checkExecutionMode(); |
422 |
< |
invocationCount++; |
430 |
> |
invoked(); |
431 |
|
throw new CFException(); |
432 |
|
} |
433 |
|
} |
434 |
< |
static final class FailingBiConsumer implements BiConsumer<Integer, Integer> { |
435 |
< |
final ExecutionMode m; |
436 |
< |
int invocationCount = 0; |
437 |
< |
FailingBiConsumer(ExecutionMode m) { this.m = m; } |
434 |
> |
|
435 |
> |
class FailingBiConsumer extends CheckedAction |
436 |
> |
implements BiConsumer<Integer, Integer> |
437 |
> |
{ |
438 |
> |
FailingBiConsumer(ExecutionMode m) { super(m); } |
439 |
|
public void accept(Integer x, Integer y) { |
440 |
< |
m.checkExecutionMode(); |
432 |
< |
invocationCount++; |
440 |
> |
invoked(); |
441 |
|
throw new CFException(); |
442 |
|
} |
443 |
|
} |
444 |
< |
static final class FailingFunction implements Function<Integer, Integer> { |
445 |
< |
final ExecutionMode m; |
446 |
< |
int invocationCount = 0; |
447 |
< |
FailingFunction(ExecutionMode m) { this.m = m; } |
444 |
> |
|
445 |
> |
class FailingFunction extends CheckedAction |
446 |
> |
implements Function<Integer, Integer> |
447 |
> |
{ |
448 |
> |
FailingFunction(ExecutionMode m) { super(m); } |
449 |
|
public Integer apply(Integer x) { |
450 |
< |
m.checkExecutionMode(); |
442 |
< |
invocationCount++; |
450 |
> |
invoked(); |
451 |
|
throw new CFException(); |
452 |
|
} |
453 |
|
} |
454 |
< |
static final class FailingBiFunction implements BiFunction<Integer, Integer, Integer> { |
455 |
< |
final ExecutionMode m; |
456 |
< |
int invocationCount = 0; |
457 |
< |
FailingBiFunction(ExecutionMode m) { this.m = m; } |
454 |
> |
|
455 |
> |
class FailingBiFunction extends CheckedAction |
456 |
> |
implements BiFunction<Integer, Integer, Integer> |
457 |
> |
{ |
458 |
> |
FailingBiFunction(ExecutionMode m) { super(m); } |
459 |
|
public Integer apply(Integer x, Integer y) { |
460 |
< |
m.checkExecutionMode(); |
452 |
< |
invocationCount++; |
460 |
> |
invoked(); |
461 |
|
throw new CFException(); |
462 |
|
} |
463 |
|
} |
464 |
< |
static final class FailingRunnable implements Runnable { |
465 |
< |
final ExecutionMode m; |
466 |
< |
int invocationCount = 0; |
459 |
< |
FailingRunnable(ExecutionMode m) { this.m = m; } |
464 |
> |
|
465 |
> |
class FailingRunnable extends CheckedAction implements Runnable { |
466 |
> |
FailingRunnable(ExecutionMode m) { super(m); } |
467 |
|
public void run() { |
468 |
< |
m.checkExecutionMode(); |
462 |
< |
invocationCount++; |
468 |
> |
invoked(); |
469 |
|
throw new CFException(); |
470 |
|
} |
471 |
|
} |
472 |
|
|
473 |
< |
static final class CompletableFutureInc |
474 |
< |
implements Function<Integer, CompletableFuture<Integer>> { |
475 |
< |
final ExecutionMode m; |
476 |
< |
int invocationCount = 0; |
477 |
< |
CompletableFutureInc(ExecutionMode m) { this.m = m; } |
473 |
> |
|
474 |
> |
class CompletableFutureInc extends CheckedAction |
475 |
> |
implements Function<Integer, CompletableFuture<Integer>> |
476 |
> |
{ |
477 |
> |
CompletableFutureInc(ExecutionMode m) { super(m); } |
478 |
|
public CompletableFuture<Integer> apply(Integer x) { |
479 |
< |
m.checkExecutionMode(); |
474 |
< |
invocationCount++; |
479 |
> |
invoked(); |
480 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
481 |
|
f.complete(inc(x)); |
482 |
|
return f; |
483 |
|
} |
484 |
|
} |
485 |
|
|
486 |
< |
static final class FailingCompletableFutureFunction |
487 |
< |
implements Function<Integer, CompletableFuture<Integer>> { |
488 |
< |
final ExecutionMode m; |
489 |
< |
int invocationCount = 0; |
485 |
< |
FailingCompletableFutureFunction(ExecutionMode m) { this.m = m; } |
486 |
> |
class FailingCompletableFutureFunction extends CheckedAction |
487 |
> |
implements Function<Integer, CompletableFuture<Integer>> |
488 |
> |
{ |
489 |
> |
FailingCompletableFutureFunction(ExecutionMode m) { super(m); } |
490 |
|
public CompletableFuture<Integer> apply(Integer x) { |
491 |
< |
m.checkExecutionMode(); |
488 |
< |
invocationCount++; |
491 |
> |
invoked(); |
492 |
|
throw new CFException(); |
493 |
|
} |
494 |
|
} |
1000 |
|
final CompletableFuture<Void> f = m.runAsync(r); |
1001 |
|
assertNull(f.join()); |
1002 |
|
checkCompletedNormally(f, null); |
1003 |
< |
assertEquals(1, r.invocationCount); |
1003 |
> |
r.assertInvoked(); |
1004 |
|
}} |
1005 |
|
|
1006 |
|
/** |
1016 |
|
final FailingRunnable r = new FailingRunnable(m); |
1017 |
|
final CompletableFuture<Void> f = m.runAsync(r); |
1018 |
|
checkCompletedWithWrappedCFException(f); |
1019 |
< |
assertEquals(1, r.invocationCount); |
1019 |
> |
r.assertInvoked(); |
1020 |
|
}} |
1021 |
|
|
1022 |
|
/** |
1034 |
|
final CompletableFuture<Integer> f = m.supplyAsync(r); |
1035 |
|
assertSame(v1, f.join()); |
1036 |
|
checkCompletedNormally(f, v1); |
1037 |
< |
assertEquals(1, r.invocationCount); |
1037 |
> |
r.assertInvoked(); |
1038 |
|
}} |
1039 |
|
|
1040 |
|
/** |
1050 |
|
FailingSupplier r = new FailingSupplier(m); |
1051 |
|
CompletableFuture<Integer> f = m.supplyAsync(r); |
1052 |
|
checkCompletedWithWrappedCFException(f); |
1053 |
< |
assertEquals(1, r.invocationCount); |
1053 |
> |
r.assertInvoked(); |
1054 |
|
}} |
1055 |
|
|
1056 |
|
// seq completion methods |
1074 |
|
|
1075 |
|
checkCompletedNormally(g, null); |
1076 |
|
checkCompletedNormally(f, v1); |
1077 |
< |
assertEquals(1, r.invocationCount); |
1077 |
> |
r.assertInvoked(); |
1078 |
|
}} |
1079 |
|
|
1080 |
|
/** |
1097 |
|
|
1098 |
|
checkCompletedWithWrappedCFException(g, ex); |
1099 |
|
checkCompletedWithWrappedCFException(f, ex); |
1100 |
< |
assertEquals(0, r.invocationCount); |
1100 |
> |
r.assertNotInvoked(); |
1101 |
|
}} |
1102 |
|
|
1103 |
|
/** |
1119 |
|
|
1120 |
|
checkCompletedWithWrappedCancellationException(g); |
1121 |
|
checkCancelled(f); |
1122 |
< |
assertEquals(0, r.invocationCount); |
1122 |
> |
r.assertNotInvoked(); |
1123 |
|
}} |
1124 |
|
|
1125 |
|
/** |
1162 |
|
|
1163 |
|
checkCompletedNormally(g, inc(v1)); |
1164 |
|
checkCompletedNormally(f, v1); |
1165 |
< |
assertEquals(1, r.invocationCount); |
1165 |
> |
r.assertInvoked(); |
1166 |
|
}} |
1167 |
|
|
1168 |
|
/** |
1185 |
|
|
1186 |
|
checkCompletedWithWrappedCFException(g, ex); |
1187 |
|
checkCompletedWithWrappedCFException(f, ex); |
1188 |
< |
assertEquals(0, r.invocationCount); |
1188 |
> |
r.assertNotInvoked(); |
1189 |
|
}} |
1190 |
|
|
1191 |
|
/** |
1207 |
|
|
1208 |
|
checkCompletedWithWrappedCancellationException(g); |
1209 |
|
checkCancelled(f); |
1210 |
< |
assertEquals(0, r.invocationCount); |
1210 |
> |
r.assertNotInvoked(); |
1211 |
|
}} |
1212 |
|
|
1213 |
|
/** |
1240 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1241 |
|
{ |
1242 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1243 |
< |
final IncAction r = new IncAction(); |
1243 |
> |
final IncAction r = new IncAction(m); |
1244 |
|
if (!createIncomplete) f.complete(v1); |
1245 |
|
final CompletableFuture<Void> g = m.thenAccept(f, r); |
1246 |
|
if (createIncomplete) { |
1250 |
|
|
1251 |
|
checkCompletedNormally(g, null); |
1252 |
|
checkCompletedNormally(f, v1); |
1253 |
< |
assertEquals(1, r.invocationCount); |
1254 |
< |
assertEquals(inc(v1), r.value); |
1253 |
> |
r.assertInvoked(); |
1254 |
> |
r.assertValue(inc(v1)); |
1255 |
|
}} |
1256 |
|
|
1257 |
|
/** |
1264 |
|
{ |
1265 |
|
final CFException ex = new CFException(); |
1266 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1267 |
< |
final IncAction r = new IncAction(); |
1267 |
> |
final IncAction r = new IncAction(m); |
1268 |
|
if (!createIncomplete) f.completeExceptionally(ex); |
1269 |
|
final CompletableFuture<Void> g = m.thenAccept(f, r); |
1270 |
|
if (createIncomplete) { |
1274 |
|
|
1275 |
|
checkCompletedWithWrappedCFException(g, ex); |
1276 |
|
checkCompletedWithWrappedCFException(f, ex); |
1277 |
< |
assertEquals(0, r.invocationCount); |
1277 |
> |
r.assertNotInvoked(); |
1278 |
|
}} |
1279 |
|
|
1280 |
|
/** |
1281 |
< |
* thenAccept result completes exceptionally if action does |
1281 |
> |
* thenAccept result completes exceptionally if source cancelled |
1282 |
|
*/ |
1283 |
< |
public void testThenAccept_actionFailed() { |
1283 |
> |
public void testThenAccept_sourceCancelled() { |
1284 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1285 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
1286 |
< |
for (Integer v1 : new Integer[] { 1, null }) |
1286 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1287 |
|
{ |
1288 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1289 |
< |
final FailingConsumer r = new FailingConsumer(m); |
1290 |
< |
if (!createIncomplete) f.complete(v1); |
1289 |
> |
final IncAction r = new IncAction(m); |
1290 |
> |
if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); |
1291 |
|
final CompletableFuture<Void> g = m.thenAccept(f, r); |
1292 |
|
if (createIncomplete) { |
1293 |
|
checkIncomplete(g); |
1294 |
< |
f.complete(v1); |
1294 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
1295 |
|
} |
1296 |
|
|
1297 |
< |
checkCompletedWithWrappedCFException(g); |
1298 |
< |
checkCompletedNormally(f, v1); |
1297 |
> |
checkCompletedWithWrappedCancellationException(g); |
1298 |
> |
checkCancelled(f); |
1299 |
> |
r.assertNotInvoked(); |
1300 |
|
}} |
1301 |
|
|
1302 |
|
/** |
1303 |
< |
* thenAccept result completes exceptionally if source cancelled |
1303 |
> |
* thenAccept result completes exceptionally if action does |
1304 |
|
*/ |
1305 |
< |
public void testThenAccept_sourceCancelled() { |
1305 |
> |
public void testThenAccept_actionFailed() { |
1306 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1307 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
1308 |
< |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1308 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1309 |
|
{ |
1310 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1311 |
< |
final IncAction r = new IncAction(); |
1312 |
< |
if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); |
1311 |
> |
final FailingConsumer r = new FailingConsumer(m); |
1312 |
> |
if (!createIncomplete) f.complete(v1); |
1313 |
|
final CompletableFuture<Void> g = m.thenAccept(f, r); |
1314 |
|
if (createIncomplete) { |
1315 |
|
checkIncomplete(g); |
1316 |
< |
assertTrue(f.cancel(mayInterruptIfRunning)); |
1316 |
> |
f.complete(v1); |
1317 |
|
} |
1318 |
|
|
1319 |
< |
checkCompletedWithWrappedCancellationException(g); |
1320 |
< |
checkCancelled(f); |
1317 |
< |
assertEquals(0, r.invocationCount); |
1319 |
> |
checkCompletedWithWrappedCFException(g); |
1320 |
> |
checkCompletedNormally(f, v1); |
1321 |
|
}} |
1322 |
|
|
1323 |
|
/** |
1341 |
|
final CompletableFuture<Integer> h = m.thenCombine(f, g, r); |
1342 |
|
if (createIncomplete) { |
1343 |
|
checkIncomplete(h); |
1344 |
< |
assertEquals(0, r.invocationCount); |
1344 |
> |
r.assertNotInvoked(); |
1345 |
|
if (!fFirst) f.complete(v1); else g.complete(v2); |
1346 |
|
} |
1347 |
|
|
1348 |
|
checkCompletedNormally(h, subtract(v1, v2)); |
1349 |
|
checkCompletedNormally(f, v1); |
1350 |
|
checkCompletedNormally(g, v2); |
1351 |
< |
assertEquals(1, r.invocationCount); |
1351 |
> |
r.assertInvoked(); |
1352 |
|
}} |
1353 |
|
|
1354 |
|
/** |
1376 |
|
} |
1377 |
|
|
1378 |
|
checkCompletedWithWrappedCFException(h, ex); |
1379 |
< |
assertEquals(0, r.invocationCount); |
1379 |
> |
r.assertNotInvoked(); |
1380 |
|
checkCompletedNormally(fFirst ? f : g, v1); |
1381 |
|
checkCompletedWithWrappedCFException(!fFirst ? f : g, ex); |
1382 |
|
}} |
1383 |
|
|
1384 |
|
/** |
1382 |
– |
* thenCombine result completes exceptionally if action does |
1383 |
– |
*/ |
1384 |
– |
public void testThenCombine_actionFailed() { |
1385 |
– |
for (ExecutionMode m : ExecutionMode.values()) |
1386 |
– |
for (boolean fFirst : new boolean[] { true, false }) |
1387 |
– |
for (Integer v1 : new Integer[] { 1, null }) |
1388 |
– |
for (Integer v2 : new Integer[] { 2, null }) |
1389 |
– |
{ |
1390 |
– |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1391 |
– |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1392 |
– |
final FailingBiFunction r = new FailingBiFunction(m); |
1393 |
– |
final CompletableFuture<Integer> h = m.thenCombine(f, g, r); |
1394 |
– |
|
1395 |
– |
if (fFirst) { |
1396 |
– |
f.complete(v1); |
1397 |
– |
g.complete(v2); |
1398 |
– |
} else { |
1399 |
– |
g.complete(v2); |
1400 |
– |
f.complete(v1); |
1401 |
– |
} |
1402 |
– |
|
1403 |
– |
checkCompletedWithWrappedCFException(h); |
1404 |
– |
checkCompletedNormally(f, v1); |
1405 |
– |
checkCompletedNormally(g, v2); |
1406 |
– |
}} |
1407 |
– |
|
1408 |
– |
/** |
1385 |
|
* thenCombine result completes exceptionally if either source cancelled |
1386 |
|
*/ |
1387 |
|
public void testThenCombine_sourceCancelled() { |
1406 |
|
|
1407 |
|
checkCompletedWithWrappedCancellationException(h); |
1408 |
|
checkCancelled(!fFirst ? f : g); |
1409 |
< |
assertEquals(0, r.invocationCount); |
1409 |
> |
r.assertNotInvoked(); |
1410 |
|
checkCompletedNormally(fFirst ? f : g, v1); |
1411 |
|
}} |
1412 |
|
|
1413 |
|
/** |
1414 |
+ |
* thenCombine result completes exceptionally if action does |
1415 |
+ |
*/ |
1416 |
+ |
public void testThenCombine_actionFailed() { |
1417 |
+ |
for (ExecutionMode m : ExecutionMode.values()) |
1418 |
+ |
for (boolean fFirst : new boolean[] { true, false }) |
1419 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
1420 |
+ |
for (Integer v2 : new Integer[] { 2, null }) |
1421 |
+ |
{ |
1422 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1423 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1424 |
+ |
final FailingBiFunction r = new FailingBiFunction(m); |
1425 |
+ |
final CompletableFuture<Integer> h = m.thenCombine(f, g, r); |
1426 |
+ |
|
1427 |
+ |
if (fFirst) { |
1428 |
+ |
f.complete(v1); |
1429 |
+ |
g.complete(v2); |
1430 |
+ |
} else { |
1431 |
+ |
g.complete(v2); |
1432 |
+ |
f.complete(v1); |
1433 |
+ |
} |
1434 |
+ |
|
1435 |
+ |
checkCompletedWithWrappedCFException(h); |
1436 |
+ |
checkCompletedNormally(f, v1); |
1437 |
+ |
checkCompletedNormally(g, v2); |
1438 |
+ |
}} |
1439 |
+ |
|
1440 |
+ |
/** |
1441 |
|
* thenAcceptBoth result completes normally after normal |
1442 |
|
* completion of sources |
1443 |
|
*/ |
1458 |
|
final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r); |
1459 |
|
if (createIncomplete) { |
1460 |
|
checkIncomplete(h); |
1461 |
< |
assertEquals(0, r.invocationCount); |
1461 |
> |
r.assertNotInvoked(); |
1462 |
|
if (!fFirst) f.complete(v1); else g.complete(v2); |
1463 |
|
} |
1464 |
|
|
1465 |
|
checkCompletedNormally(h, null); |
1466 |
< |
assertEquals(subtract(v1, v2), r.value); |
1466 |
> |
r.assertValue(subtract(v1, v2)); |
1467 |
|
checkCompletedNormally(f, v1); |
1468 |
|
checkCompletedNormally(g, v2); |
1469 |
|
}} |
1493 |
|
} |
1494 |
|
|
1495 |
|
checkCompletedWithWrappedCFException(h, ex); |
1496 |
< |
assertEquals(0, r.invocationCount); |
1496 |
> |
r.assertNotInvoked(); |
1497 |
|
checkCompletedNormally(fFirst ? f : g, v1); |
1498 |
|
checkCompletedWithWrappedCFException(!fFirst ? f : g, ex); |
1499 |
|
}} |
1500 |
|
|
1501 |
|
/** |
1499 |
– |
* thenAcceptBoth result completes exceptionally if action does |
1500 |
– |
*/ |
1501 |
– |
public void testThenAcceptBoth_actionFailed() { |
1502 |
– |
for (ExecutionMode m : ExecutionMode.values()) |
1503 |
– |
for (boolean fFirst : new boolean[] { true, false }) |
1504 |
– |
for (Integer v1 : new Integer[] { 1, null }) |
1505 |
– |
for (Integer v2 : new Integer[] { 2, null }) |
1506 |
– |
{ |
1507 |
– |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1508 |
– |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1509 |
– |
final FailingBiConsumer r = new FailingBiConsumer(m); |
1510 |
– |
final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r); |
1511 |
– |
|
1512 |
– |
if (fFirst) { |
1513 |
– |
f.complete(v1); |
1514 |
– |
g.complete(v2); |
1515 |
– |
} else { |
1516 |
– |
g.complete(v2); |
1517 |
– |
f.complete(v1); |
1518 |
– |
} |
1519 |
– |
|
1520 |
– |
checkCompletedWithWrappedCFException(h); |
1521 |
– |
checkCompletedNormally(f, v1); |
1522 |
– |
checkCompletedNormally(g, v2); |
1523 |
– |
}} |
1524 |
– |
|
1525 |
– |
/** |
1502 |
|
* thenAcceptBoth result completes exceptionally if either source cancelled |
1503 |
|
*/ |
1504 |
|
public void testThenAcceptBoth_sourceCancelled() { |
1523 |
|
|
1524 |
|
checkCompletedWithWrappedCancellationException(h); |
1525 |
|
checkCancelled(!fFirst ? f : g); |
1526 |
< |
assertEquals(0, r.invocationCount); |
1526 |
> |
r.assertNotInvoked(); |
1527 |
|
checkCompletedNormally(fFirst ? f : g, v1); |
1528 |
|
}} |
1529 |
|
|
1530 |
|
/** |
1531 |
+ |
* thenAcceptBoth result completes exceptionally if action does |
1532 |
+ |
*/ |
1533 |
+ |
public void testThenAcceptBoth_actionFailed() { |
1534 |
+ |
for (ExecutionMode m : ExecutionMode.values()) |
1535 |
+ |
for (boolean fFirst : new boolean[] { true, false }) |
1536 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
1537 |
+ |
for (Integer v2 : new Integer[] { 2, null }) |
1538 |
+ |
{ |
1539 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1540 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1541 |
+ |
final FailingBiConsumer r = new FailingBiConsumer(m); |
1542 |
+ |
final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r); |
1543 |
+ |
|
1544 |
+ |
if (fFirst) { |
1545 |
+ |
f.complete(v1); |
1546 |
+ |
g.complete(v2); |
1547 |
+ |
} else { |
1548 |
+ |
g.complete(v2); |
1549 |
+ |
f.complete(v1); |
1550 |
+ |
} |
1551 |
+ |
|
1552 |
+ |
checkCompletedWithWrappedCFException(h); |
1553 |
+ |
checkCompletedNormally(f, v1); |
1554 |
+ |
checkCompletedNormally(g, v2); |
1555 |
+ |
}} |
1556 |
+ |
|
1557 |
+ |
/** |
1558 |
|
* runAfterBoth result completes normally after normal |
1559 |
|
* completion of sources |
1560 |
|
*/ |
1575 |
|
final CompletableFuture<Void> h = m.runAfterBoth(f, g, r); |
1576 |
|
if (createIncomplete) { |
1577 |
|
checkIncomplete(h); |
1578 |
< |
assertEquals(0, r.invocationCount); |
1578 |
> |
r.assertNotInvoked(); |
1579 |
|
if (!fFirst) f.complete(v1); else g.complete(v2); |
1580 |
|
} |
1581 |
|
|
1582 |
|
checkCompletedNormally(h, null); |
1583 |
< |
assertEquals(1, r.invocationCount); |
1583 |
> |
r.assertInvoked(); |
1584 |
|
checkCompletedNormally(f, v1); |
1585 |
|
checkCompletedNormally(g, v2); |
1586 |
|
}} |
1610 |
|
} |
1611 |
|
|
1612 |
|
checkCompletedWithWrappedCFException(h, ex); |
1613 |
< |
assertEquals(0, r.invocationCount); |
1613 |
> |
r.assertNotInvoked(); |
1614 |
|
checkCompletedNormally(fFirst ? f : g, v1); |
1615 |
|
checkCompletedWithWrappedCFException(!fFirst ? f : g, ex); |
1616 |
|
}} |
1617 |
|
|
1618 |
|
/** |
1616 |
– |
* runAfterBoth result completes exceptionally if action does |
1617 |
– |
*/ |
1618 |
– |
public void testRunAfterBoth_actionFailed() { |
1619 |
– |
for (ExecutionMode m : ExecutionMode.values()) |
1620 |
– |
for (boolean fFirst : new boolean[] { true, false }) |
1621 |
– |
for (Integer v1 : new Integer[] { 1, null }) |
1622 |
– |
for (Integer v2 : new Integer[] { 2, null }) |
1623 |
– |
{ |
1624 |
– |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1625 |
– |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1626 |
– |
final FailingRunnable r = new FailingRunnable(m); |
1627 |
– |
|
1628 |
– |
CompletableFuture<Void> h1 = m.runAfterBoth(f, g, r); |
1629 |
– |
if (fFirst) { |
1630 |
– |
f.complete(v1); |
1631 |
– |
g.complete(v2); |
1632 |
– |
} else { |
1633 |
– |
g.complete(v2); |
1634 |
– |
f.complete(v1); |
1635 |
– |
} |
1636 |
– |
CompletableFuture<Void> h2 = m.runAfterBoth(f, g, r); |
1637 |
– |
|
1638 |
– |
checkCompletedWithWrappedCFException(h1); |
1639 |
– |
checkCompletedWithWrappedCFException(h2); |
1640 |
– |
checkCompletedNormally(f, v1); |
1641 |
– |
checkCompletedNormally(g, v2); |
1642 |
– |
}} |
1643 |
– |
|
1644 |
– |
/** |
1619 |
|
* runAfterBoth result completes exceptionally if either source cancelled |
1620 |
|
*/ |
1621 |
|
public void testRunAfterBoth_sourceCancelled() { |
1641 |
|
|
1642 |
|
checkCompletedWithWrappedCancellationException(h); |
1643 |
|
checkCancelled(!fFirst ? f : g); |
1644 |
< |
assertEquals(0, r.invocationCount); |
1644 |
> |
r.assertNotInvoked(); |
1645 |
|
checkCompletedNormally(fFirst ? f : g, v1); |
1646 |
|
}} |
1647 |
|
|
1648 |
|
/** |
1649 |
< |
* applyToEither result completes normally after normal completion |
1676 |
< |
* of either source |
1649 |
> |
* runAfterBoth result completes exceptionally if action does |
1650 |
|
*/ |
1651 |
< |
public void testApplyToEither_normalCompletion() { |
1651 |
> |
public void testRunAfterBoth_actionFailed() { |
1652 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1680 |
– |
for (boolean createIncomplete : new boolean[] { true, false }) |
1653 |
|
for (boolean fFirst : new boolean[] { true, false }) |
1654 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1655 |
|
for (Integer v2 : new Integer[] { 2, null }) |
1656 |
|
{ |
1657 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1658 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1659 |
< |
final IncFunction r = new IncFunction(m); |
1659 |
> |
final FailingRunnable r1 = new FailingRunnable(m); |
1660 |
> |
final FailingRunnable r2 = new FailingRunnable(m); |
1661 |
|
|
1662 |
< |
if (!createIncomplete) |
1663 |
< |
if (fFirst) f.complete(v1); else g.complete(v2); |
1664 |
< |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1665 |
< |
if (createIncomplete) { |
1666 |
< |
checkIncomplete(h); |
1667 |
< |
assertEquals(0, r.invocationCount); |
1668 |
< |
if (fFirst) f.complete(v1); else g.complete(v2); |
1662 |
> |
CompletableFuture<Void> h1 = m.runAfterBoth(f, g, r1); |
1663 |
> |
if (fFirst) { |
1664 |
> |
f.complete(v1); |
1665 |
> |
g.complete(v2); |
1666 |
> |
} else { |
1667 |
> |
g.complete(v2); |
1668 |
> |
f.complete(v1); |
1669 |
|
} |
1670 |
< |
checkCompletedNormally(h, inc(fFirst ? v1 : v2)); |
1698 |
< |
if (!fFirst) f.complete(v1); else g.complete(v2); |
1670 |
> |
CompletableFuture<Void> h2 = m.runAfterBoth(f, g, r2); |
1671 |
|
|
1672 |
+ |
checkCompletedWithWrappedCFException(h1); |
1673 |
+ |
checkCompletedWithWrappedCFException(h2); |
1674 |
|
checkCompletedNormally(f, v1); |
1675 |
|
checkCompletedNormally(g, v2); |
1702 |
– |
checkCompletedNormally(h, inc(fFirst ? v1 : v2)); |
1676 |
|
}} |
1677 |
|
|
1678 |
< |
public void testApplyToEither_normalCompletionBothAvailable() { |
1678 |
> |
/** |
1679 |
> |
* applyToEither result completes normally after normal completion |
1680 |
> |
* of either source |
1681 |
> |
*/ |
1682 |
> |
public void testApplyToEither_normalCompletion() { |
1683 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1707 |
– |
for (boolean fFirst : new boolean[] { true, false }) |
1684 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1685 |
|
for (Integer v2 : new Integer[] { 2, null }) |
1686 |
|
{ |
1687 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1688 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1689 |
< |
final IncFunction r = new IncFunction(m); |
1689 |
> |
final IncFunction[] rs = new IncFunction[6]; |
1690 |
> |
for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); |
1691 |
|
|
1692 |
< |
if (fFirst) { |
1693 |
< |
f.complete(v1); |
1694 |
< |
g.complete(v2); |
1695 |
< |
} else { |
1696 |
< |
g.complete(v2); |
1697 |
< |
f.complete(v1); |
1698 |
< |
} |
1692 |
> |
final CompletableFuture<Integer> h0 = m.applyToEither(f, g, rs[0]); |
1693 |
> |
final CompletableFuture<Integer> h1 = m.applyToEither(g, f, rs[1]); |
1694 |
> |
checkIncomplete(h0); |
1695 |
> |
checkIncomplete(h1); |
1696 |
> |
rs[0].assertNotInvoked(); |
1697 |
> |
rs[1].assertNotInvoked(); |
1698 |
> |
f.complete(v1); |
1699 |
> |
checkCompletedNormally(h0, inc(v1)); |
1700 |
> |
checkCompletedNormally(h1, inc(v1)); |
1701 |
> |
final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]); |
1702 |
> |
final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]); |
1703 |
> |
checkCompletedNormally(h2, inc(v1)); |
1704 |
> |
checkCompletedNormally(h3, inc(v1)); |
1705 |
> |
g.complete(v2); |
1706 |
|
|
1707 |
< |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1707 |
> |
// unspecified behavior - both source completions available |
1708 |
> |
final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]); |
1709 |
> |
final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]); |
1710 |
> |
rs[4].assertValue(h4.join()); |
1711 |
> |
rs[5].assertValue(h5.join()); |
1712 |
> |
assertTrue(Objects.equals(inc(v1), h4.join()) || |
1713 |
> |
Objects.equals(inc(v2), h4.join())); |
1714 |
> |
assertTrue(Objects.equals(inc(v1), h5.join()) || |
1715 |
> |
Objects.equals(inc(v2), h5.join())); |
1716 |
|
|
1717 |
|
checkCompletedNormally(f, v1); |
1718 |
|
checkCompletedNormally(g, v2); |
1719 |
< |
|
1720 |
< |
// unspecified behavior |
1721 |
< |
assertTrue(Objects.equals(h.join(), inc(v1)) || |
1722 |
< |
Objects.equals(h.join(), inc(v2))); |
1723 |
< |
assertEquals(1, r.invocationCount); |
1719 |
> |
checkCompletedNormally(h0, inc(v1)); |
1720 |
> |
checkCompletedNormally(h1, inc(v1)); |
1721 |
> |
checkCompletedNormally(h2, inc(v1)); |
1722 |
> |
checkCompletedNormally(h3, inc(v1)); |
1723 |
> |
for (int i = 0; i < 4; i++) rs[i].assertValue(inc(v1)); |
1724 |
|
}} |
1725 |
|
|
1726 |
|
/** |
1727 |
|
* applyToEither result completes exceptionally after exceptional |
1728 |
|
* completion of either source |
1729 |
|
*/ |
1730 |
< |
public void testApplyToEither_exceptionalCompletion1() { |
1730 |
> |
public void testApplyToEither_exceptionalCompletion() { |
1731 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1740 |
– |
for (boolean createIncomplete : new boolean[] { true, false }) |
1741 |
– |
for (boolean fFirst : new boolean[] { true, false }) |
1732 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1733 |
|
{ |
1734 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1735 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1736 |
|
final CFException ex = new CFException(); |
1737 |
< |
final IncFunction r = new IncFunction(m); |
1737 |
> |
final IncFunction[] rs = new IncFunction[6]; |
1738 |
> |
for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); |
1739 |
|
|
1740 |
< |
if (!createIncomplete) (fFirst ? f : g).completeExceptionally(ex); |
1741 |
< |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1742 |
< |
if (createIncomplete) { |
1743 |
< |
checkIncomplete(h); |
1744 |
< |
assertEquals(0, r.invocationCount); |
1745 |
< |
(fFirst ? f : g).completeExceptionally(ex); |
1746 |
< |
} |
1740 |
> |
final CompletableFuture<Integer> h0 = m.applyToEither(f, g, rs[0]); |
1741 |
> |
final CompletableFuture<Integer> h1 = m.applyToEither(g, f, rs[1]); |
1742 |
> |
checkIncomplete(h0); |
1743 |
> |
checkIncomplete(h1); |
1744 |
> |
rs[0].assertNotInvoked(); |
1745 |
> |
rs[1].assertNotInvoked(); |
1746 |
> |
f.completeExceptionally(ex); |
1747 |
> |
checkCompletedWithWrappedCFException(h0, ex); |
1748 |
> |
checkCompletedWithWrappedCFException(h1, ex); |
1749 |
> |
final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]); |
1750 |
> |
final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]); |
1751 |
> |
checkCompletedWithWrappedCFException(h2, ex); |
1752 |
> |
checkCompletedWithWrappedCFException(h3, ex); |
1753 |
> |
g.complete(v1); |
1754 |
|
|
1755 |
< |
checkCompletedWithWrappedCFException(h, ex); |
1756 |
< |
(!fFirst ? f : g).complete(v1); |
1755 |
> |
// unspecified behavior - both source completions available |
1756 |
> |
final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]); |
1757 |
> |
final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]); |
1758 |
> |
try { |
1759 |
> |
assertEquals(inc(v1), h4.join()); |
1760 |
> |
rs[4].assertInvoked(); |
1761 |
> |
} catch (CompletionException ok) { |
1762 |
> |
checkCompletedWithWrappedCFException(h4, ex); |
1763 |
> |
rs[4].assertNotInvoked(); |
1764 |
> |
} |
1765 |
> |
try { |
1766 |
> |
assertEquals(inc(v1), h5.join()); |
1767 |
> |
rs[5].assertInvoked(); |
1768 |
> |
} catch (CompletionException ok) { |
1769 |
> |
checkCompletedWithWrappedCFException(h5, ex); |
1770 |
> |
rs[5].assertNotInvoked(); |
1771 |
> |
} |
1772 |
|
|
1773 |
< |
assertEquals(0, r.invocationCount); |
1774 |
< |
checkCompletedNormally(!fFirst ? f : g, v1); |
1775 |
< |
checkCompletedWithWrappedCFException(fFirst ? f : g, ex); |
1776 |
< |
checkCompletedWithWrappedCFException(h, ex); |
1773 |
> |
checkCompletedWithWrappedCFException(f, ex); |
1774 |
> |
checkCompletedNormally(g, v1); |
1775 |
> |
checkCompletedWithWrappedCFException(h0, ex); |
1776 |
> |
checkCompletedWithWrappedCFException(h1, ex); |
1777 |
> |
checkCompletedWithWrappedCFException(h2, ex); |
1778 |
> |
checkCompletedWithWrappedCFException(h3, ex); |
1779 |
> |
checkCompletedWithWrappedCFException(h4, ex); |
1780 |
> |
for (int i = 0; i < 4; i++) rs[i].assertNotInvoked(); |
1781 |
|
}} |
1782 |
|
|
1783 |
< |
public void testApplyToEither_exceptionalCompletion2() { |
1783 |
> |
/** |
1784 |
> |
* applyToEither result completes exceptionally if either source cancelled |
1785 |
> |
*/ |
1786 |
> |
public void testApplyToEither_sourceCancelled() { |
1787 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1788 |
< |
for (boolean reverseArgs : new boolean[] { true, false }) |
1769 |
< |
for (boolean fFirst : new boolean[] { true, false }) |
1788 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1789 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1790 |
|
{ |
1791 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1792 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1793 |
< |
final IncFunction r1 = new IncFunction(m); |
1794 |
< |
final IncFunction r2 = new IncFunction(m); |
1776 |
< |
final CFException ex = new CFException(); |
1777 |
< |
final CompletableFuture<Integer> j = (reverseArgs ? g : f); |
1778 |
< |
final CompletableFuture<Integer> k = (reverseArgs ? f : g); |
1779 |
< |
final CompletableFuture<Integer> h1 = m.applyToEither(j, k, r1); |
1780 |
< |
if (fFirst) { |
1781 |
< |
f.complete(v1); |
1782 |
< |
g.completeExceptionally(ex); |
1783 |
< |
} else { |
1784 |
< |
g.completeExceptionally(ex); |
1785 |
< |
f.complete(v1); |
1786 |
< |
} |
1787 |
< |
final CompletableFuture<Integer> h2 = m.applyToEither(j, k, r2); |
1793 |
> |
final IncFunction[] rs = new IncFunction[6]; |
1794 |
> |
for (int i = 0; i < rs.length; i++) rs[i] = new IncFunction(m); |
1795 |
|
|
1796 |
< |
// unspecified behavior |
1796 |
> |
final CompletableFuture<Integer> h0 = m.applyToEither(f, g, rs[0]); |
1797 |
> |
final CompletableFuture<Integer> h1 = m.applyToEither(g, f, rs[1]); |
1798 |
> |
checkIncomplete(h0); |
1799 |
> |
checkIncomplete(h1); |
1800 |
> |
rs[0].assertNotInvoked(); |
1801 |
> |
rs[1].assertNotInvoked(); |
1802 |
> |
f.cancel(mayInterruptIfRunning); |
1803 |
> |
checkCompletedWithWrappedCancellationException(h0); |
1804 |
> |
checkCompletedWithWrappedCancellationException(h1); |
1805 |
> |
final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]); |
1806 |
> |
final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]); |
1807 |
> |
checkCompletedWithWrappedCancellationException(h2); |
1808 |
> |
checkCompletedWithWrappedCancellationException(h3); |
1809 |
> |
g.complete(v1); |
1810 |
> |
|
1811 |
> |
// unspecified behavior - both source completions available |
1812 |
> |
final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]); |
1813 |
> |
final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]); |
1814 |
|
try { |
1815 |
< |
assertEquals(inc(v1), h1.join()); |
1816 |
< |
assertEquals(1, r1.invocationCount); |
1815 |
> |
assertEquals(inc(v1), h4.join()); |
1816 |
> |
rs[4].assertInvoked(); |
1817 |
|
} catch (CompletionException ok) { |
1818 |
< |
checkCompletedWithWrappedCFException(h1, ex); |
1819 |
< |
assertEquals(0, r1.invocationCount); |
1818 |
> |
checkCompletedWithWrappedCancellationException(h4); |
1819 |
> |
rs[4].assertNotInvoked(); |
1820 |
|
} |
1797 |
– |
|
1821 |
|
try { |
1822 |
< |
assertEquals(inc(v1), h2.join()); |
1823 |
< |
assertEquals(1, r2.invocationCount); |
1822 |
> |
assertEquals(inc(v1), h5.join()); |
1823 |
> |
rs[5].assertInvoked(); |
1824 |
|
} catch (CompletionException ok) { |
1825 |
< |
checkCompletedWithWrappedCFException(h2, ex); |
1826 |
< |
assertEquals(0, r2.invocationCount); |
1825 |
> |
checkCompletedWithWrappedCancellationException(h5); |
1826 |
> |
rs[5].assertNotInvoked(); |
1827 |
|
} |
1828 |
|
|
1829 |
< |
checkCompletedWithWrappedCFException(g, ex); |
1830 |
< |
checkCompletedNormally(f, v1); |
1829 |
> |
checkCancelled(f); |
1830 |
> |
checkCompletedNormally(g, v1); |
1831 |
> |
checkCompletedWithWrappedCancellationException(h0); |
1832 |
> |
checkCompletedWithWrappedCancellationException(h1); |
1833 |
> |
checkCompletedWithWrappedCancellationException(h2); |
1834 |
> |
checkCompletedWithWrappedCancellationException(h3); |
1835 |
> |
for (int i = 0; i < 4; i++) rs[i].assertNotInvoked(); |
1836 |
|
}} |
1837 |
|
|
1838 |
|
/** |
1839 |
|
* applyToEither result completes exceptionally if action does |
1840 |
|
*/ |
1841 |
< |
public void testApplyToEither_actionFailed1() { |
1841 |
> |
public void testApplyToEither_actionFailed() { |
1842 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1843 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1844 |
|
for (Integer v2 : new Integer[] { 2, null }) |
1845 |
|
{ |
1846 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1847 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1848 |
< |
final FailingFunction r = new FailingFunction(m); |
1849 |
< |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1848 |
> |
final FailingFunction[] rs = new FailingFunction[6]; |
1849 |
> |
for (int i = 0; i < rs.length; i++) rs[i] = new FailingFunction(m); |
1850 |
|
|
1851 |
+ |
final CompletableFuture<Integer> h0 = m.applyToEither(f, g, rs[0]); |
1852 |
+ |
final CompletableFuture<Integer> h1 = m.applyToEither(g, f, rs[1]); |
1853 |
|
f.complete(v1); |
1854 |
< |
checkCompletedWithWrappedCFException(h); |
1854 |
> |
final CompletableFuture<Integer> h2 = m.applyToEither(f, g, rs[2]); |
1855 |
> |
final CompletableFuture<Integer> h3 = m.applyToEither(g, f, rs[3]); |
1856 |
|
g.complete(v2); |
1857 |
+ |
final CompletableFuture<Integer> h4 = m.applyToEither(f, g, rs[4]); |
1858 |
+ |
final CompletableFuture<Integer> h5 = m.applyToEither(g, f, rs[5]); |
1859 |
+ |
|
1860 |
|
checkCompletedNormally(f, v1); |
1861 |
|
checkCompletedNormally(g, v2); |
1862 |
< |
}} |
1863 |
< |
|
1864 |
< |
public void testApplyToEither_actionFailed2() { |
1865 |
< |
for (ExecutionMode m : ExecutionMode.values()) |
1866 |
< |
for (Integer v1 : new Integer[] { 1, null }) |
1867 |
< |
for (Integer v2 : new Integer[] { 2, null }) |
1868 |
< |
{ |
1835 |
< |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1836 |
< |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1837 |
< |
final FailingFunction r = new FailingFunction(m); |
1838 |
< |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1839 |
< |
|
1840 |
< |
g.complete(v2); |
1841 |
< |
checkCompletedWithWrappedCFException(h); |
1842 |
< |
f.complete(v1); |
1843 |
< |
checkCompletedNormally(f, v1); |
1844 |
< |
checkCompletedNormally(g, v2); |
1845 |
< |
}} |
1846 |
< |
|
1847 |
< |
/** |
1848 |
< |
* applyToEither result completes exceptionally if either source cancelled |
1849 |
< |
*/ |
1850 |
< |
public void testApplyToEither_sourceCancelled1() { |
1851 |
< |
for (ExecutionMode m : ExecutionMode.values()) |
1852 |
< |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1853 |
< |
for (boolean createIncomplete : new boolean[] { true, false }) |
1854 |
< |
for (boolean fFirst : new boolean[] { true, false }) |
1855 |
< |
for (Integer v1 : new Integer[] { 1, null }) |
1856 |
< |
{ |
1857 |
< |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1858 |
< |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1859 |
< |
final IncFunction r = new IncFunction(m); |
1860 |
< |
|
1861 |
< |
if (!createIncomplete) assertTrue((fFirst ? f : g).cancel(mayInterruptIfRunning)); |
1862 |
< |
final CompletableFuture<Integer> h = m.applyToEither(f, g, r); |
1863 |
< |
if (createIncomplete) { |
1864 |
< |
checkIncomplete(h); |
1865 |
< |
assertEquals(0, r.invocationCount); |
1866 |
< |
assertTrue((fFirst ? f : g).cancel(mayInterruptIfRunning)); |
1867 |
< |
} |
1868 |
< |
|
1869 |
< |
checkCompletedWithWrappedCancellationException(h); |
1870 |
< |
(!fFirst ? f : g).complete(v1); |
1871 |
< |
|
1872 |
< |
assertEquals(0, r.invocationCount); |
1873 |
< |
checkCompletedNormally(!fFirst ? f : g, v1); |
1874 |
< |
checkCancelled(fFirst ? f : g); |
1875 |
< |
checkCompletedWithWrappedCancellationException(h); |
1876 |
< |
}} |
1877 |
< |
|
1878 |
< |
public void testApplyToEither_sourceCancelled2() { |
1879 |
< |
for (ExecutionMode m : ExecutionMode.values()) |
1880 |
< |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1881 |
< |
for (boolean reverseArgs : new boolean[] { true, false }) |
1882 |
< |
for (boolean fFirst : new boolean[] { true, false }) |
1883 |
< |
for (Integer v1 : new Integer[] { 1, null }) |
1884 |
< |
{ |
1885 |
< |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1886 |
< |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1887 |
< |
final IncFunction r1 = new IncFunction(m); |
1888 |
< |
final IncFunction r2 = new IncFunction(m); |
1889 |
< |
final CFException ex = new CFException(); |
1890 |
< |
final CompletableFuture<Integer> j = (reverseArgs ? g : f); |
1891 |
< |
final CompletableFuture<Integer> k = (reverseArgs ? f : g); |
1892 |
< |
|
1893 |
< |
final CompletableFuture<Integer> h1 = m.applyToEither(j, k, r1); |
1894 |
< |
if (fFirst) { |
1895 |
< |
f.complete(v1); |
1896 |
< |
assertTrue(g.cancel(mayInterruptIfRunning)); |
1897 |
< |
} else { |
1898 |
< |
assertTrue(g.cancel(mayInterruptIfRunning)); |
1899 |
< |
f.complete(v1); |
1900 |
< |
} |
1901 |
< |
final CompletableFuture<Integer> h2 = m.applyToEither(j, k, r2); |
1902 |
< |
|
1903 |
< |
// unspecified behavior |
1904 |
< |
try { |
1905 |
< |
assertEquals(inc(v1), h1.join()); |
1906 |
< |
assertEquals(1, r1.invocationCount); |
1907 |
< |
} catch (CompletionException ok) { |
1908 |
< |
checkCompletedWithWrappedCancellationException(h1); |
1909 |
< |
assertEquals(0, r1.invocationCount); |
1910 |
< |
} |
1911 |
< |
|
1912 |
< |
try { |
1913 |
< |
assertEquals(inc(v1), h2.join()); |
1914 |
< |
assertEquals(1, r2.invocationCount); |
1915 |
< |
} catch (CompletionException ok) { |
1916 |
< |
checkCompletedWithWrappedCancellationException(h2); |
1917 |
< |
assertEquals(0, r2.invocationCount); |
1918 |
< |
} |
1919 |
< |
|
1920 |
< |
checkCancelled(g); |
1921 |
< |
checkCompletedNormally(f, v1); |
1862 |
> |
checkCompletedWithWrappedCFException(h0); |
1863 |
> |
checkCompletedWithWrappedCFException(h1); |
1864 |
> |
checkCompletedWithWrappedCFException(h2); |
1865 |
> |
checkCompletedWithWrappedCFException(h3); |
1866 |
> |
checkCompletedWithWrappedCFException(h4); |
1867 |
> |
checkCompletedWithWrappedCFException(h5); |
1868 |
> |
for (int i = 0; i < rs.length; i++) rs[i].assertInvoked(); |
1869 |
|
}} |
1870 |
|
|
1871 |
|
/** |
1879 |
|
{ |
1880 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1881 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1882 |
< |
final IncAction r = new IncAction(); |
1882 |
> |
final IncAction r = new IncAction(m); |
1883 |
|
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
1884 |
|
|
1885 |
|
f.complete(v1); |
1899 |
|
{ |
1900 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1901 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1902 |
< |
final IncAction r = new IncAction(); |
1902 |
> |
final IncAction r = new IncAction(m); |
1903 |
|
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
1904 |
|
|
1905 |
|
g.complete(v2); |
1919 |
|
{ |
1920 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1921 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1922 |
< |
final IncAction r = new IncAction(); |
1922 |
> |
final IncAction r = new IncAction(m); |
1923 |
|
|
1924 |
|
f.complete(v1); |
1925 |
|
g.complete(v2); |
1944 |
|
{ |
1945 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1946 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1947 |
< |
final IncAction r = new IncAction(); |
1947 |
> |
final IncAction r = new IncAction(m); |
1948 |
|
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
1949 |
|
final CFException ex = new CFException(); |
1950 |
|
|
1952 |
|
checkCompletedWithWrappedCFException(h, ex); |
1953 |
|
g.complete(v1); |
1954 |
|
|
1955 |
< |
assertEquals(0, r.invocationCount); |
1955 |
> |
r.assertNotInvoked(); |
1956 |
|
checkCompletedNormally(g, v1); |
1957 |
|
checkCompletedWithWrappedCFException(f, ex); |
1958 |
|
checkCompletedWithWrappedCFException(h, ex); |
1964 |
|
{ |
1965 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1966 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1967 |
< |
final IncAction r = new IncAction(); |
1967 |
> |
final IncAction r = new IncAction(m); |
1968 |
|
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
1969 |
|
final CFException ex = new CFException(); |
1970 |
|
|
1972 |
|
checkCompletedWithWrappedCFException(h, ex); |
1973 |
|
f.complete(v1); |
1974 |
|
|
1975 |
< |
assertEquals(0, r.invocationCount); |
1975 |
> |
r.assertNotInvoked(); |
1976 |
|
checkCompletedNormally(f, v1); |
1977 |
|
checkCompletedWithWrappedCFException(g, ex); |
1978 |
|
checkCompletedWithWrappedCFException(h, ex); |
1984 |
|
{ |
1985 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1986 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1987 |
< |
final IncAction r = new IncAction(); |
1987 |
> |
final IncAction r = new IncAction(m); |
1988 |
|
final CFException ex = new CFException(); |
1989 |
|
|
1990 |
|
g.completeExceptionally(ex); |
1995 |
|
Integer v; |
1996 |
|
try { |
1997 |
|
assertNull(h.join()); |
1998 |
< |
assertEquals(1, r.invocationCount); |
1998 |
> |
r.assertInvoked(); |
1999 |
|
assertEquals(inc(v1), r.value); |
2000 |
|
} catch (CompletionException ok) { |
2001 |
|
checkCompletedWithWrappedCFException(h, ex); |
2002 |
< |
assertEquals(0, r.invocationCount); |
2002 |
> |
r.assertNotInvoked(); |
2003 |
|
} |
2004 |
|
|
2005 |
|
checkCompletedWithWrappedCFException(g, ex); |
2012 |
|
{ |
2013 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2014 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2015 |
< |
final IncAction r = new IncAction(); |
2015 |
> |
final IncAction r = new IncAction(m); |
2016 |
|
final CFException ex = new CFException(); |
2017 |
|
|
2018 |
|
f.completeExceptionally(ex); |
2023 |
|
Integer v; |
2024 |
|
try { |
2025 |
|
assertNull(h.join()); |
2026 |
< |
assertEquals(1, r.invocationCount); |
2026 |
> |
r.assertInvoked(); |
2027 |
|
assertEquals(inc(v1), r.value); |
2028 |
|
} catch (CompletionException ok) { |
2029 |
|
checkCompletedWithWrappedCFException(h, ex); |
2030 |
< |
assertEquals(0, r.invocationCount); |
2030 |
> |
r.assertNotInvoked(); |
2031 |
|
} |
2032 |
|
|
2033 |
|
checkCompletedWithWrappedCFException(f, ex); |
2081 |
|
{ |
2082 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2083 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2084 |
< |
final IncAction r = new IncAction(); |
2084 |
> |
final IncAction r = new IncAction(m); |
2085 |
|
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2086 |
|
|
2087 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
2089 |
|
g.complete(v1); |
2090 |
|
|
2091 |
|
checkCancelled(f); |
2092 |
< |
assertEquals(0, r.invocationCount); |
2092 |
> |
r.assertNotInvoked(); |
2093 |
|
checkCompletedNormally(g, v1); |
2094 |
|
checkCompletedWithWrappedCancellationException(h); |
2095 |
|
}} |
2101 |
|
{ |
2102 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2103 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2104 |
< |
final IncAction r = new IncAction(); |
2104 |
> |
final IncAction r = new IncAction(m); |
2105 |
|
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2106 |
|
|
2107 |
|
assertTrue(g.cancel(mayInterruptIfRunning)); |
2109 |
|
f.complete(v1); |
2110 |
|
|
2111 |
|
checkCancelled(g); |
2112 |
< |
assertEquals(0, r.invocationCount); |
2112 |
> |
r.assertNotInvoked(); |
2113 |
|
checkCompletedNormally(f, v1); |
2114 |
|
checkCompletedWithWrappedCancellationException(h); |
2115 |
|
}} |
2121 |
|
{ |
2122 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2123 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2124 |
< |
final IncAction r = new IncAction(); |
2124 |
> |
final IncAction r = new IncAction(m); |
2125 |
|
|
2126 |
|
assertTrue(g.cancel(mayInterruptIfRunning)); |
2127 |
|
f.complete(v1); |
2131 |
|
Integer v; |
2132 |
|
try { |
2133 |
|
assertNull(h.join()); |
2134 |
< |
assertEquals(1, r.invocationCount); |
2134 |
> |
r.assertInvoked(); |
2135 |
|
assertEquals(inc(v1), r.value); |
2136 |
|
} catch (CompletionException ok) { |
2137 |
|
checkCompletedWithWrappedCancellationException(h); |
2138 |
< |
assertEquals(0, r.invocationCount); |
2138 |
> |
r.assertNotInvoked(); |
2139 |
|
} |
2140 |
|
|
2141 |
|
checkCancelled(g); |
2149 |
|
{ |
2150 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2151 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2152 |
< |
final IncAction r = new IncAction(); |
2152 |
> |
final IncAction r = new IncAction(m); |
2153 |
|
|
2154 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
2155 |
|
g.complete(v1); |
2159 |
|
Integer v; |
2160 |
|
try { |
2161 |
|
assertNull(h.join()); |
2162 |
< |
assertEquals(1, r.invocationCount); |
2162 |
> |
r.assertInvoked(); |
2163 |
|
assertEquals(inc(v1), r.value); |
2164 |
|
} catch (CompletionException ok) { |
2165 |
|
checkCompletedWithWrappedCancellationException(h); |
2166 |
< |
assertEquals(0, r.invocationCount); |
2166 |
> |
r.assertNotInvoked(); |
2167 |
|
} |
2168 |
|
|
2169 |
|
checkCancelled(f); |
2186 |
|
|
2187 |
|
f.complete(v1); |
2188 |
|
checkCompletedNormally(h, null); |
2189 |
< |
assertEquals(1, r.invocationCount); |
2189 |
> |
r.assertInvoked(); |
2190 |
|
g.complete(v2); |
2191 |
|
|
2192 |
|
checkCompletedNormally(f, v1); |
2193 |
|
checkCompletedNormally(g, v2); |
2194 |
|
checkCompletedNormally(h, null); |
2195 |
< |
assertEquals(1, r.invocationCount); |
2195 |
> |
r.assertInvoked(); |
2196 |
|
}} |
2197 |
|
|
2198 |
|
public void testRunAfterEither_normalCompletion2() { |
2207 |
|
|
2208 |
|
g.complete(v2); |
2209 |
|
checkCompletedNormally(h, null); |
2210 |
< |
assertEquals(1, r.invocationCount); |
2210 |
> |
r.assertInvoked(); |
2211 |
|
f.complete(v1); |
2212 |
|
|
2213 |
|
checkCompletedNormally(f, v1); |
2214 |
|
checkCompletedNormally(g, v2); |
2215 |
|
checkCompletedNormally(h, null); |
2216 |
< |
assertEquals(1, r.invocationCount); |
2216 |
> |
r.assertInvoked(); |
2217 |
|
}} |
2218 |
|
|
2219 |
|
public void testRunAfterEither_normalCompletion3() { |
2232 |
|
checkCompletedNormally(h, null); |
2233 |
|
checkCompletedNormally(f, v1); |
2234 |
|
checkCompletedNormally(g, v2); |
2235 |
< |
assertEquals(1, r.invocationCount); |
2235 |
> |
r.assertInvoked(); |
2236 |
|
}} |
2237 |
|
|
2238 |
|
/** |
2253 |
|
checkCompletedWithWrappedCFException(h, ex); |
2254 |
|
g.complete(v1); |
2255 |
|
|
2256 |
< |
assertEquals(0, r.invocationCount); |
2256 |
> |
r.assertNotInvoked(); |
2257 |
|
checkCompletedNormally(g, v1); |
2258 |
|
checkCompletedWithWrappedCFException(f, ex); |
2259 |
|
checkCompletedWithWrappedCFException(h, ex); |
2273 |
|
checkCompletedWithWrappedCFException(h, ex); |
2274 |
|
f.complete(v1); |
2275 |
|
|
2276 |
< |
assertEquals(0, r.invocationCount); |
2276 |
> |
r.assertNotInvoked(); |
2277 |
|
checkCompletedNormally(f, v1); |
2278 |
|
checkCompletedWithWrappedCFException(g, ex); |
2279 |
|
checkCompletedWithWrappedCFException(h, ex); |
2296 |
|
Integer v; |
2297 |
|
try { |
2298 |
|
assertNull(h.join()); |
2299 |
< |
assertEquals(1, r.invocationCount); |
2299 |
> |
r.assertInvoked(); |
2300 |
|
} catch (CompletionException ok) { |
2301 |
|
checkCompletedWithWrappedCFException(h, ex); |
2302 |
< |
assertEquals(0, r.invocationCount); |
2302 |
> |
r.assertNotInvoked(); |
2303 |
|
} |
2304 |
|
|
2305 |
|
checkCompletedWithWrappedCFException(g, ex); |
2323 |
|
Integer v; |
2324 |
|
try { |
2325 |
|
assertNull(h.join()); |
2326 |
< |
assertEquals(1, r.invocationCount); |
2326 |
> |
r.assertInvoked(); |
2327 |
|
} catch (CompletionException ok) { |
2328 |
|
checkCompletedWithWrappedCFException(h, ex); |
2329 |
< |
assertEquals(0, r.invocationCount); |
2329 |
> |
r.assertNotInvoked(); |
2330 |
|
} |
2331 |
|
|
2332 |
|
checkCompletedWithWrappedCFException(f, ex); |
2388 |
|
g.complete(v1); |
2389 |
|
|
2390 |
|
checkCancelled(f); |
2391 |
< |
assertEquals(0, r.invocationCount); |
2391 |
> |
r.assertNotInvoked(); |
2392 |
|
checkCompletedNormally(g, v1); |
2393 |
|
checkCompletedWithWrappedCancellationException(h); |
2394 |
|
}} |
2408 |
|
f.complete(v1); |
2409 |
|
|
2410 |
|
checkCancelled(g); |
2411 |
< |
assertEquals(0, r.invocationCount); |
2411 |
> |
r.assertNotInvoked(); |
2412 |
|
checkCompletedNormally(f, v1); |
2413 |
|
checkCompletedWithWrappedCancellationException(h); |
2414 |
|
}} |
2430 |
|
Integer v; |
2431 |
|
try { |
2432 |
|
assertNull(h.join()); |
2433 |
< |
assertEquals(1, r.invocationCount); |
2433 |
> |
r.assertInvoked(); |
2434 |
|
} catch (CompletionException ok) { |
2435 |
|
checkCompletedWithWrappedCancellationException(h); |
2436 |
< |
assertEquals(0, r.invocationCount); |
2436 |
> |
r.assertNotInvoked(); |
2437 |
|
} |
2438 |
|
|
2439 |
|
checkCancelled(g); |
2457 |
|
Integer v; |
2458 |
|
try { |
2459 |
|
assertNull(h.join()); |
2460 |
< |
assertEquals(1, r.invocationCount); |
2460 |
> |
r.assertInvoked(); |
2461 |
|
} catch (CompletionException ok) { |
2462 |
|
checkCompletedWithWrappedCancellationException(h); |
2463 |
< |
assertEquals(0, r.invocationCount); |
2463 |
> |
r.assertNotInvoked(); |
2464 |
|
} |
2465 |
|
|
2466 |
|
checkCancelled(f); |
2483 |
|
|
2484 |
|
checkCompletedNormally(g, inc(v1)); |
2485 |
|
checkCompletedNormally(f, v1); |
2486 |
< |
assertEquals(1, r.invocationCount); |
2486 |
> |
r.assertInvoked(); |
2487 |
|
}} |
2488 |
|
|
2489 |
|
/** |
2503 |
|
|
2504 |
|
checkCompletedWithWrappedCFException(g, ex); |
2505 |
|
checkCompletedWithWrappedCFException(f, ex); |
2506 |
< |
assertEquals(0, r.invocationCount); |
2506 |
> |
r.assertNotInvoked(); |
2507 |
|
}} |
2508 |
|
|
2509 |
|
/** |