1275 |
|
}} |
1276 |
|
|
1277 |
|
/** |
1278 |
< |
* thenAccept result completes exceptionally if action does |
1278 |
> |
* thenAccept result completes exceptionally if source cancelled |
1279 |
|
*/ |
1280 |
< |
public void testThenAccept_actionFailed() { |
1280 |
> |
public void testThenAccept_sourceCancelled() { |
1281 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1282 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
1283 |
< |
for (Integer v1 : new Integer[] { 1, null }) |
1283 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1284 |
|
{ |
1285 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1286 |
< |
final FailingConsumer r = new FailingConsumer(m); |
1287 |
< |
if (!createIncomplete) f.complete(v1); |
1286 |
> |
final IncAction r = new IncAction(); |
1287 |
> |
if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); |
1288 |
|
final CompletableFuture<Void> g = m.thenAccept(f, r); |
1289 |
|
if (createIncomplete) { |
1290 |
|
checkIncomplete(g); |
1291 |
< |
f.complete(v1); |
1291 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
1292 |
|
} |
1293 |
|
|
1294 |
< |
checkCompletedWithWrappedCFException(g); |
1295 |
< |
checkCompletedNormally(f, v1); |
1294 |
> |
checkCompletedWithWrappedCancellationException(g); |
1295 |
> |
checkCancelled(f); |
1296 |
> |
assertEquals(0, r.invocationCount); |
1297 |
|
}} |
1298 |
|
|
1299 |
|
/** |
1300 |
< |
* thenAccept result completes exceptionally if source cancelled |
1300 |
> |
* thenAccept result completes exceptionally if action does |
1301 |
|
*/ |
1302 |
< |
public void testThenAccept_sourceCancelled() { |
1302 |
> |
public void testThenAccept_actionFailed() { |
1303 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1304 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
1305 |
< |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1305 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1306 |
|
{ |
1307 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1308 |
< |
final IncAction r = new IncAction(); |
1309 |
< |
if (!createIncomplete) assertTrue(f.cancel(mayInterruptIfRunning)); |
1308 |
> |
final FailingConsumer r = new FailingConsumer(m); |
1309 |
> |
if (!createIncomplete) f.complete(v1); |
1310 |
|
final CompletableFuture<Void> g = m.thenAccept(f, r); |
1311 |
|
if (createIncomplete) { |
1312 |
|
checkIncomplete(g); |
1313 |
< |
assertTrue(f.cancel(mayInterruptIfRunning)); |
1313 |
> |
f.complete(v1); |
1314 |
|
} |
1315 |
|
|
1316 |
< |
checkCompletedWithWrappedCancellationException(g); |
1317 |
< |
checkCancelled(f); |
1317 |
< |
assertEquals(0, r.invocationCount); |
1316 |
> |
checkCompletedWithWrappedCFException(g); |
1317 |
> |
checkCompletedNormally(f, v1); |
1318 |
|
}} |
1319 |
|
|
1320 |
|
/** |
1379 |
|
}} |
1380 |
|
|
1381 |
|
/** |
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 |
– |
/** |
1382 |
|
* thenCombine result completes exceptionally if either source cancelled |
1383 |
|
*/ |
1384 |
|
public void testThenCombine_sourceCancelled() { |
1408 |
|
}} |
1409 |
|
|
1410 |
|
/** |
1411 |
+ |
* thenCombine result completes exceptionally if action does |
1412 |
+ |
*/ |
1413 |
+ |
public void testThenCombine_actionFailed() { |
1414 |
+ |
for (ExecutionMode m : ExecutionMode.values()) |
1415 |
+ |
for (boolean fFirst : new boolean[] { true, false }) |
1416 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
1417 |
+ |
for (Integer v2 : new Integer[] { 2, null }) |
1418 |
+ |
{ |
1419 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1420 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1421 |
+ |
final FailingBiFunction r = new FailingBiFunction(m); |
1422 |
+ |
final CompletableFuture<Integer> h = m.thenCombine(f, g, r); |
1423 |
+ |
|
1424 |
+ |
if (fFirst) { |
1425 |
+ |
f.complete(v1); |
1426 |
+ |
g.complete(v2); |
1427 |
+ |
} else { |
1428 |
+ |
g.complete(v2); |
1429 |
+ |
f.complete(v1); |
1430 |
+ |
} |
1431 |
+ |
|
1432 |
+ |
checkCompletedWithWrappedCFException(h); |
1433 |
+ |
checkCompletedNormally(f, v1); |
1434 |
+ |
checkCompletedNormally(g, v2); |
1435 |
+ |
}} |
1436 |
+ |
|
1437 |
+ |
/** |
1438 |
|
* thenAcceptBoth result completes normally after normal |
1439 |
|
* completion of sources |
1440 |
|
*/ |
1496 |
|
}} |
1497 |
|
|
1498 |
|
/** |
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 |
– |
/** |
1499 |
|
* thenAcceptBoth result completes exceptionally if either source cancelled |
1500 |
|
*/ |
1501 |
|
public void testThenAcceptBoth_sourceCancelled() { |
1525 |
|
}} |
1526 |
|
|
1527 |
|
/** |
1528 |
+ |
* thenAcceptBoth result completes exceptionally if action does |
1529 |
+ |
*/ |
1530 |
+ |
public void testThenAcceptBoth_actionFailed() { |
1531 |
+ |
for (ExecutionMode m : ExecutionMode.values()) |
1532 |
+ |
for (boolean fFirst : new boolean[] { true, false }) |
1533 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
1534 |
+ |
for (Integer v2 : new Integer[] { 2, null }) |
1535 |
+ |
{ |
1536 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1537 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1538 |
+ |
final FailingBiConsumer r = new FailingBiConsumer(m); |
1539 |
+ |
final CompletableFuture<Void> h = m.thenAcceptBoth(f, g, r); |
1540 |
+ |
|
1541 |
+ |
if (fFirst) { |
1542 |
+ |
f.complete(v1); |
1543 |
+ |
g.complete(v2); |
1544 |
+ |
} else { |
1545 |
+ |
g.complete(v2); |
1546 |
+ |
f.complete(v1); |
1547 |
+ |
} |
1548 |
+ |
|
1549 |
+ |
checkCompletedWithWrappedCFException(h); |
1550 |
+ |
checkCompletedNormally(f, v1); |
1551 |
+ |
checkCompletedNormally(g, v2); |
1552 |
+ |
}} |
1553 |
+ |
|
1554 |
+ |
/** |
1555 |
|
* runAfterBoth result completes normally after normal |
1556 |
|
* completion of sources |
1557 |
|
*/ |
1613 |
|
}} |
1614 |
|
|
1615 |
|
/** |
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 |
– |
/** |
1616 |
|
* runAfterBoth result completes exceptionally if either source cancelled |
1617 |
|
*/ |
1618 |
|
public void testRunAfterBoth_sourceCancelled() { |
1643 |
|
}} |
1644 |
|
|
1645 |
|
/** |
1646 |
+ |
* runAfterBoth result completes exceptionally if action does |
1647 |
+ |
*/ |
1648 |
+ |
public void testRunAfterBoth_actionFailed() { |
1649 |
+ |
for (ExecutionMode m : ExecutionMode.values()) |
1650 |
+ |
for (boolean fFirst : new boolean[] { true, false }) |
1651 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
1652 |
+ |
for (Integer v2 : new Integer[] { 2, null }) |
1653 |
+ |
{ |
1654 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1655 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1656 |
+ |
final FailingRunnable r = new FailingRunnable(m); |
1657 |
+ |
|
1658 |
+ |
CompletableFuture<Void> h1 = m.runAfterBoth(f, g, r); |
1659 |
+ |
if (fFirst) { |
1660 |
+ |
f.complete(v1); |
1661 |
+ |
g.complete(v2); |
1662 |
+ |
} else { |
1663 |
+ |
g.complete(v2); |
1664 |
+ |
f.complete(v1); |
1665 |
+ |
} |
1666 |
+ |
CompletableFuture<Void> h2 = m.runAfterBoth(f, g, r); |
1667 |
+ |
|
1668 |
+ |
checkCompletedWithWrappedCFException(h1); |
1669 |
+ |
checkCompletedWithWrappedCFException(h2); |
1670 |
+ |
checkCompletedNormally(f, v1); |
1671 |
+ |
checkCompletedNormally(g, v2); |
1672 |
+ |
}} |
1673 |
+ |
|
1674 |
+ |
/** |
1675 |
|
* applyToEither result completes normally after normal completion |
1676 |
|
* of either source |
1677 |
|
*/ |