1136 |
|
for (boolean fFirst : new boolean[] { true, false }) |
1137 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1138 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1139 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1140 |
< |
|
1139 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1140 |
> |
{ |
1141 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1142 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1143 |
|
final SubtractFunction r = new SubtractFunction(); |
1160 |
|
checkCompletedNormally(f, v1); |
1161 |
|
checkCompletedNormally(g, v2); |
1162 |
|
assertEquals(1, r.invocationCount); |
1163 |
< |
} |
1164 |
< |
} |
1163 |
> |
}} |
1164 |
|
|
1165 |
|
/** |
1166 |
|
* thenCombine result completes exceptionally after exceptional |
1168 |
|
*/ |
1169 |
|
public void testThenCombine_exceptionalCompletion1() { |
1170 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1171 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1172 |
< |
|
1171 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1172 |
> |
{ |
1173 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1174 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1175 |
|
final SubtractFunction r = new SubtractFunction(); |
1184 |
|
checkCompletedWithWrappedCFException(f, ex); |
1185 |
|
assertEquals(0, r.invocationCount); |
1186 |
|
checkCompletedNormally(g, v1); |
1187 |
< |
} |
1189 |
< |
} |
1187 |
> |
}} |
1188 |
|
|
1189 |
|
public void testThenCombine_exceptionalCompletion2() { |
1190 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1191 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1192 |
< |
|
1191 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1192 |
> |
{ |
1193 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1194 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1195 |
|
final SubtractFunction r = new SubtractFunction(); |
1204 |
|
checkCompletedWithWrappedCFException(g, ex); |
1205 |
|
assertEquals(0, r.invocationCount); |
1206 |
|
checkCompletedNormally(f, v1); |
1207 |
< |
} |
1210 |
< |
} |
1207 |
> |
}} |
1208 |
|
|
1209 |
|
public void testThenCombine_exceptionalCompletion3() { |
1210 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1211 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1212 |
< |
|
1211 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1212 |
> |
{ |
1213 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1214 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1215 |
|
final SubtractFunction r = new SubtractFunction(); |
1223 |
|
checkCompletedWithWrappedCFException(g, ex); |
1224 |
|
assertEquals(0, r.invocationCount); |
1225 |
|
checkCompletedNormally(f, v1); |
1226 |
< |
} |
1230 |
< |
} |
1226 |
> |
}} |
1227 |
|
|
1228 |
|
public void testThenCombine_exceptionalCompletion4() { |
1229 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1230 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1231 |
< |
|
1230 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1231 |
> |
{ |
1232 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1233 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1234 |
|
final SubtractFunction r = new SubtractFunction(); |
1242 |
|
checkCompletedWithWrappedCFException(f, ex); |
1243 |
|
assertEquals(0, r.invocationCount); |
1244 |
|
checkCompletedNormally(g, v1); |
1245 |
< |
} |
1250 |
< |
} |
1245 |
> |
}} |
1246 |
|
|
1247 |
|
/** |
1248 |
|
* thenCombine result completes exceptionally if action does |
1250 |
|
public void testThenCombine_actionFailed1() { |
1251 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1252 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1253 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1254 |
< |
|
1253 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1254 |
> |
{ |
1255 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1256 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1257 |
|
final FailingBiFunction r = new FailingBiFunction(); |
1264 |
|
checkCompletedWithWrappedCFException(h); |
1265 |
|
checkCompletedNormally(f, v1); |
1266 |
|
checkCompletedNormally(g, v2); |
1267 |
< |
} |
1273 |
< |
} |
1267 |
> |
}} |
1268 |
|
|
1269 |
|
public void testThenCombine_actionFailed2() { |
1270 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1271 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1272 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1273 |
< |
|
1272 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1273 |
> |
{ |
1274 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1275 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1276 |
|
final FailingBiFunction r = new FailingBiFunction(); |
1283 |
|
checkCompletedWithWrappedCFException(h); |
1284 |
|
checkCompletedNormally(f, v1); |
1285 |
|
checkCompletedNormally(g, v2); |
1286 |
< |
} |
1293 |
< |
} |
1286 |
> |
}} |
1287 |
|
|
1288 |
|
/** |
1289 |
|
* thenCombine result completes exceptionally if either source cancelled |
1291 |
|
public void testThenCombine_sourceCancelled1() { |
1292 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1293 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1294 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1295 |
< |
|
1294 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1295 |
> |
{ |
1296 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1297 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1298 |
|
final SubtractFunction r = new SubtractFunction(); |
1306 |
|
checkCancelled(f); |
1307 |
|
assertEquals(0, r.invocationCount); |
1308 |
|
checkCompletedNormally(g, v1); |
1309 |
< |
} |
1317 |
< |
} |
1309 |
> |
}} |
1310 |
|
|
1311 |
|
public void testThenCombine_sourceCancelled2() { |
1312 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1313 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1314 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1315 |
< |
|
1314 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1315 |
> |
{ |
1316 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1317 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1318 |
|
final SubtractFunction r = new SubtractFunction(); |
1326 |
|
checkCancelled(g); |
1327 |
|
assertEquals(0, r.invocationCount); |
1328 |
|
checkCompletedNormally(f, v1); |
1329 |
< |
} |
1338 |
< |
} |
1329 |
> |
}} |
1330 |
|
|
1331 |
|
public void testThenCombine_sourceCancelled3() { |
1332 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1333 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1334 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1335 |
< |
|
1334 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1335 |
> |
{ |
1336 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1337 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1338 |
|
final SubtractFunction r = new SubtractFunction(); |
1345 |
|
checkCancelled(g); |
1346 |
|
assertEquals(0, r.invocationCount); |
1347 |
|
checkCompletedNormally(f, v1); |
1348 |
< |
} |
1358 |
< |
} |
1348 |
> |
}} |
1349 |
|
|
1350 |
|
public void testThenCombine_sourceCancelled4() { |
1351 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1352 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1353 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1354 |
< |
|
1353 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1354 |
> |
{ |
1355 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1356 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1357 |
|
final SubtractFunction r = new SubtractFunction(); |
1364 |
|
checkCancelled(f); |
1365 |
|
assertEquals(0, r.invocationCount); |
1366 |
|
checkCompletedNormally(g, v1); |
1367 |
< |
} |
1378 |
< |
} |
1367 |
> |
}} |
1368 |
|
|
1369 |
|
/** |
1370 |
|
* thenAcceptBoth result completes normally after normal |
1373 |
|
public void testThenAcceptBoth_normalCompletion1() { |
1374 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1375 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1376 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1377 |
< |
|
1376 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1377 |
> |
{ |
1378 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1379 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1380 |
|
final SubtractAction r = new SubtractAction(); |
1389 |
|
assertEquals(subtract(v1, v2), r.value); |
1390 |
|
checkCompletedNormally(f, v1); |
1391 |
|
checkCompletedNormally(g, v2); |
1392 |
< |
} |
1404 |
< |
} |
1392 |
> |
}} |
1393 |
|
|
1394 |
|
public void testThenAcceptBoth_normalCompletion2() { |
1395 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1396 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1397 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1398 |
< |
|
1397 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1398 |
> |
{ |
1399 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1400 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1401 |
|
final SubtractAction r = new SubtractAction(); |
1410 |
|
assertEquals(subtract(v1, v2), r.value); |
1411 |
|
checkCompletedNormally(f, v1); |
1412 |
|
checkCompletedNormally(g, v2); |
1413 |
< |
} |
1426 |
< |
} |
1413 |
> |
}} |
1414 |
|
|
1415 |
|
public void testThenAcceptBoth_normalCompletion3() { |
1416 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1417 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1418 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1419 |
< |
|
1418 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1419 |
> |
{ |
1420 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1421 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1422 |
|
final SubtractAction r = new SubtractAction(); |
1429 |
|
assertEquals(subtract(v1, v2), r.value); |
1430 |
|
checkCompletedNormally(f, v1); |
1431 |
|
checkCompletedNormally(g, v2); |
1432 |
< |
} |
1446 |
< |
} |
1432 |
> |
}} |
1433 |
|
|
1434 |
|
public void testThenAcceptBoth_normalCompletion4() { |
1435 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1436 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1437 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1438 |
< |
|
1437 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1438 |
> |
{ |
1439 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1440 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1441 |
|
final SubtractAction r = new SubtractAction(); |
1448 |
|
assertEquals(subtract(v1, v2), r.value); |
1449 |
|
checkCompletedNormally(f, v1); |
1450 |
|
checkCompletedNormally(g, v2); |
1451 |
< |
} |
1466 |
< |
} |
1451 |
> |
}} |
1452 |
|
|
1453 |
|
/** |
1454 |
|
* thenAcceptBoth result completes exceptionally after exceptional |
1456 |
|
*/ |
1457 |
|
public void testThenAcceptBoth_exceptionalCompletion1() { |
1458 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1459 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1460 |
< |
|
1459 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1460 |
> |
{ |
1461 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1462 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1463 |
|
final SubtractAction r = new SubtractAction(); |
1472 |
|
checkCompletedWithWrappedCFException(f, ex); |
1473 |
|
assertEquals(0, r.invocationCount); |
1474 |
|
checkCompletedNormally(g, v1); |
1475 |
< |
} |
1491 |
< |
} |
1475 |
> |
}} |
1476 |
|
|
1477 |
|
public void testThenAcceptBoth_exceptionalCompletion2() { |
1478 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1479 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1480 |
< |
|
1479 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1480 |
> |
{ |
1481 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1482 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1483 |
|
final SubtractAction r = new SubtractAction(); |
1492 |
|
checkCompletedWithWrappedCFException(g, ex); |
1493 |
|
assertEquals(0, r.invocationCount); |
1494 |
|
checkCompletedNormally(f, v1); |
1495 |
< |
} |
1512 |
< |
} |
1495 |
> |
}} |
1496 |
|
|
1497 |
|
public void testThenAcceptBoth_exceptionalCompletion3() { |
1498 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1499 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1500 |
< |
|
1499 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1500 |
> |
{ |
1501 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1502 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1503 |
|
final SubtractAction r = new SubtractAction(); |
1511 |
|
checkCompletedWithWrappedCFException(g, ex); |
1512 |
|
assertEquals(0, r.invocationCount); |
1513 |
|
checkCompletedNormally(f, v1); |
1514 |
< |
} |
1532 |
< |
} |
1514 |
> |
}} |
1515 |
|
|
1516 |
|
public void testThenAcceptBoth_exceptionalCompletion4() { |
1517 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1518 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1519 |
< |
|
1518 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1519 |
> |
{ |
1520 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1521 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1522 |
|
final SubtractAction r = new SubtractAction(); |
1530 |
|
checkCompletedWithWrappedCFException(f, ex); |
1531 |
|
assertEquals(0, r.invocationCount); |
1532 |
|
checkCompletedNormally(g, v1); |
1533 |
< |
} |
1552 |
< |
} |
1533 |
> |
}} |
1534 |
|
|
1535 |
|
/** |
1536 |
|
* thenAcceptBoth result completes exceptionally if action does |
1538 |
|
public void testThenAcceptBoth_actionFailed1() { |
1539 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1540 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1541 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1542 |
< |
|
1541 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1542 |
> |
{ |
1543 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1544 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1545 |
|
final FailingBiConsumer r = new FailingBiConsumer(); |
1552 |
|
checkCompletedWithWrappedCFException(h); |
1553 |
|
checkCompletedNormally(f, v1); |
1554 |
|
checkCompletedNormally(g, v2); |
1555 |
< |
} |
1575 |
< |
} |
1555 |
> |
}} |
1556 |
|
|
1557 |
|
public void testThenAcceptBoth_actionFailed2() { |
1558 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1559 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1560 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1561 |
< |
|
1560 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1561 |
> |
{ |
1562 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1563 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1564 |
|
final FailingBiConsumer r = new FailingBiConsumer(); |
1571 |
|
checkCompletedWithWrappedCFException(h); |
1572 |
|
checkCompletedNormally(f, v1); |
1573 |
|
checkCompletedNormally(g, v2); |
1574 |
< |
} |
1595 |
< |
} |
1574 |
> |
}} |
1575 |
|
|
1576 |
|
/** |
1577 |
|
* thenAcceptBoth result completes exceptionally if either source cancelled |
1579 |
|
public void testThenAcceptBoth_sourceCancelled1() { |
1580 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1581 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1582 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1583 |
< |
|
1582 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1583 |
> |
{ |
1584 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1585 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1586 |
|
final SubtractAction r = new SubtractAction(); |
1594 |
|
checkCancelled(f); |
1595 |
|
assertEquals(0, r.invocationCount); |
1596 |
|
checkCompletedNormally(g, v1); |
1597 |
< |
} |
1619 |
< |
} |
1597 |
> |
}} |
1598 |
|
|
1599 |
|
public void testThenAcceptBoth_sourceCancelled2() { |
1600 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1601 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1602 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1603 |
< |
|
1602 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1603 |
> |
{ |
1604 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1605 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1606 |
|
final SubtractAction r = new SubtractAction(); |
1614 |
|
checkCancelled(g); |
1615 |
|
assertEquals(0, r.invocationCount); |
1616 |
|
checkCompletedNormally(f, v1); |
1617 |
< |
} |
1640 |
< |
} |
1617 |
> |
}} |
1618 |
|
|
1619 |
|
public void testThenAcceptBoth_sourceCancelled3() { |
1620 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1621 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1622 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1623 |
< |
|
1622 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1623 |
> |
{ |
1624 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1625 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1626 |
|
final SubtractAction r = new SubtractAction(); |
1633 |
|
checkCancelled(g); |
1634 |
|
assertEquals(0, r.invocationCount); |
1635 |
|
checkCompletedNormally(f, v1); |
1636 |
< |
} |
1660 |
< |
} |
1636 |
> |
}} |
1637 |
|
|
1638 |
|
public void testThenAcceptBoth_sourceCancelled4() { |
1639 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1640 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1641 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1642 |
< |
|
1641 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1642 |
> |
{ |
1643 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1644 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1645 |
|
final SubtractAction r = new SubtractAction(); |
1652 |
|
checkCancelled(f); |
1653 |
|
assertEquals(0, r.invocationCount); |
1654 |
|
checkCompletedNormally(g, v1); |
1655 |
< |
} |
1680 |
< |
} |
1655 |
> |
}} |
1656 |
|
|
1657 |
|
/** |
1658 |
|
* runAfterBoth result completes normally after normal |
1661 |
|
public void testRunAfterBoth_normalCompletion1() { |
1662 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1663 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1664 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1665 |
< |
|
1664 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1665 |
> |
{ |
1666 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1667 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1668 |
|
final Noop r = new Noop(); |
1677 |
|
assertEquals(1, r.invocationCount); |
1678 |
|
checkCompletedNormally(f, v1); |
1679 |
|
checkCompletedNormally(g, v2); |
1680 |
< |
} |
1706 |
< |
} |
1680 |
> |
}} |
1681 |
|
|
1682 |
|
public void testRunAfterBoth_normalCompletion2() { |
1683 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1684 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1685 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1686 |
< |
|
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 Noop r = new Noop(); |
1698 |
|
assertEquals(1, r.invocationCount); |
1699 |
|
checkCompletedNormally(f, v1); |
1700 |
|
checkCompletedNormally(g, v2); |
1701 |
< |
} |
1728 |
< |
} |
1701 |
> |
}} |
1702 |
|
|
1703 |
|
public void testRunAfterBoth_normalCompletion3() { |
1704 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1705 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1706 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1707 |
< |
|
1706 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1707 |
> |
{ |
1708 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1709 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1710 |
|
final Noop r = new Noop(); |
1717 |
|
assertEquals(1, r.invocationCount); |
1718 |
|
checkCompletedNormally(f, v1); |
1719 |
|
checkCompletedNormally(g, v2); |
1720 |
< |
} |
1748 |
< |
} |
1720 |
> |
}} |
1721 |
|
|
1722 |
|
public void testRunAfterBoth_normalCompletion4() { |
1723 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1724 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1725 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1726 |
< |
|
1725 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1726 |
> |
{ |
1727 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1728 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1729 |
|
final Noop r = new Noop(); |
1736 |
|
assertEquals(1, r.invocationCount); |
1737 |
|
checkCompletedNormally(f, v1); |
1738 |
|
checkCompletedNormally(g, v2); |
1739 |
< |
} |
1768 |
< |
} |
1739 |
> |
}} |
1740 |
|
|
1741 |
|
/** |
1742 |
|
* runAfterBoth result completes exceptionally after exceptional |
1744 |
|
*/ |
1745 |
|
public void testRunAfterBoth_exceptionalCompletion1() { |
1746 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1747 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1748 |
< |
|
1747 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1748 |
> |
{ |
1749 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1750 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1751 |
|
final Noop r = new Noop(); |
1760 |
|
checkCompletedWithWrappedCFException(f, ex); |
1761 |
|
assertEquals(0, r.invocationCount); |
1762 |
|
checkCompletedNormally(g, v1); |
1763 |
< |
} |
1793 |
< |
} |
1763 |
> |
}} |
1764 |
|
|
1765 |
|
public void testRunAfterBoth_exceptionalCompletion2() { |
1766 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1767 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1768 |
< |
|
1767 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1768 |
> |
{ |
1769 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1770 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1771 |
|
final Noop r = new Noop(); |
1780 |
|
checkCompletedWithWrappedCFException(g, ex); |
1781 |
|
assertEquals(0, r.invocationCount); |
1782 |
|
checkCompletedNormally(f, v1); |
1783 |
< |
} |
1814 |
< |
} |
1783 |
> |
}} |
1784 |
|
|
1785 |
|
public void testRunAfterBoth_exceptionalCompletion3() { |
1786 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1787 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1788 |
< |
|
1787 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1788 |
> |
{ |
1789 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1790 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1791 |
|
final Noop r = new Noop(); |
1799 |
|
checkCompletedWithWrappedCFException(g, ex); |
1800 |
|
assertEquals(0, r.invocationCount); |
1801 |
|
checkCompletedNormally(f, v1); |
1802 |
< |
} |
1834 |
< |
} |
1802 |
> |
}} |
1803 |
|
|
1804 |
|
public void testRunAfterBoth_exceptionalCompletion4() { |
1805 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1806 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1807 |
< |
|
1806 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1807 |
> |
{ |
1808 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1809 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1810 |
|
final Noop r = new Noop(); |
1818 |
|
checkCompletedWithWrappedCFException(f, ex); |
1819 |
|
assertEquals(0, r.invocationCount); |
1820 |
|
checkCompletedNormally(g, v1); |
1821 |
< |
} |
1854 |
< |
} |
1821 |
> |
}} |
1822 |
|
|
1823 |
|
/** |
1824 |
|
* runAfterBoth result completes exceptionally if action does |
1826 |
|
public void testRunAfterBoth_actionFailed1() { |
1827 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1828 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1829 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1830 |
< |
|
1829 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1830 |
> |
{ |
1831 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1832 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1833 |
|
final FailingNoop r = new FailingNoop(); |
1840 |
|
checkCompletedWithWrappedCFException(h); |
1841 |
|
checkCompletedNormally(f, v1); |
1842 |
|
checkCompletedNormally(g, v2); |
1843 |
< |
} |
1877 |
< |
} |
1843 |
> |
}} |
1844 |
|
|
1845 |
|
public void testRunAfterBoth_actionFailed2() { |
1846 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1847 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1848 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1849 |
< |
|
1848 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1849 |
> |
{ |
1850 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1851 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1852 |
|
final FailingNoop r = new FailingNoop(); |
1859 |
|
checkCompletedWithWrappedCFException(h); |
1860 |
|
checkCompletedNormally(f, v1); |
1861 |
|
checkCompletedNormally(g, v2); |
1862 |
< |
} |
1897 |
< |
} |
1862 |
> |
}} |
1863 |
|
|
1864 |
|
/** |
1865 |
|
* runAfterBoth result completes exceptionally if either source cancelled |
1867 |
|
public void testRunAfterBoth_sourceCancelled1() { |
1868 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1869 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1870 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1871 |
< |
|
1870 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1871 |
> |
{ |
1872 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1873 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1874 |
|
final Noop r = new Noop(); |
1882 |
|
checkCancelled(f); |
1883 |
|
assertEquals(0, r.invocationCount); |
1884 |
|
checkCompletedNormally(g, v1); |
1885 |
< |
} |
1921 |
< |
} |
1885 |
> |
}} |
1886 |
|
|
1887 |
|
public void testRunAfterBoth_sourceCancelled2() { |
1888 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1889 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1890 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1891 |
< |
|
1890 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1891 |
> |
{ |
1892 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1893 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1894 |
|
final Noop r = new Noop(); |
1902 |
|
checkCancelled(g); |
1903 |
|
assertEquals(0, r.invocationCount); |
1904 |
|
checkCompletedNormally(f, v1); |
1905 |
< |
} |
1942 |
< |
} |
1905 |
> |
}} |
1906 |
|
|
1907 |
|
public void testRunAfterBoth_sourceCancelled3() { |
1908 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1909 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1910 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1911 |
< |
|
1910 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1911 |
> |
{ |
1912 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1913 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1914 |
|
final Noop r = new Noop(); |
1921 |
|
checkCancelled(g); |
1922 |
|
assertEquals(0, r.invocationCount); |
1923 |
|
checkCompletedNormally(f, v1); |
1924 |
< |
} |
1962 |
< |
} |
1924 |
> |
}} |
1925 |
|
|
1926 |
|
public void testRunAfterBoth_sourceCancelled4() { |
1927 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1928 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1929 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
1930 |
< |
|
1929 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1930 |
> |
{ |
1931 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1932 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1933 |
|
final Noop r = new Noop(); |
1940 |
|
checkCancelled(f); |
1941 |
|
assertEquals(0, r.invocationCount); |
1942 |
|
checkCompletedNormally(g, v1); |
1943 |
< |
} |
1982 |
< |
} |
1943 |
> |
}} |
1944 |
|
|
1945 |
|
/** |
1946 |
|
* applyToEither result completes normally after normal completion |
1949 |
|
public void testApplyToEither_normalCompletion1() { |
1950 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1951 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1952 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1953 |
< |
|
1952 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1953 |
> |
{ |
1954 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1955 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1956 |
|
final IncFunction r = new IncFunction(); |
1963 |
|
checkCompletedNormally(f, v1); |
1964 |
|
checkCompletedNormally(g, v2); |
1965 |
|
checkCompletedNormally(h, inc(v1)); |
1966 |
< |
} |
2006 |
< |
} |
1966 |
> |
}} |
1967 |
|
|
1968 |
|
public void testApplyToEither_normalCompletion2() { |
1969 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1970 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1971 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1972 |
< |
|
1971 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1972 |
> |
{ |
1973 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1974 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1975 |
|
final IncFunction r = new IncFunction(); |
1982 |
|
checkCompletedNormally(f, v1); |
1983 |
|
checkCompletedNormally(g, v2); |
1984 |
|
checkCompletedNormally(h, inc(v2)); |
1985 |
< |
} |
1986 |
< |
} |
1985 |
> |
}} |
1986 |
> |
|
1987 |
|
public void testApplyToEither_normalCompletion3() { |
1988 |
|
for (ExecutionMode m : ExecutionMode.values()) |
1989 |
|
for (Integer v1 : new Integer[] { 1, null }) |
1990 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
1991 |
< |
|
1990 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
1991 |
> |
{ |
1992 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1993 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1994 |
|
final IncFunction r = new IncFunction(); |
2004 |
|
assertTrue(Objects.equals(h.join(), inc(v1)) || |
2005 |
|
Objects.equals(h.join(), inc(v2))); |
2006 |
|
assertEquals(1, r.invocationCount); |
2007 |
< |
} |
2048 |
< |
} |
2007 |
> |
}} |
2008 |
|
|
2009 |
|
/** |
2010 |
|
* applyToEither result completes exceptionally after exceptional |
2012 |
|
*/ |
2013 |
|
public void testApplyToEither_exceptionalCompletion1() { |
2014 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2015 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2016 |
< |
|
2015 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2016 |
> |
{ |
2017 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2018 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2019 |
|
final IncFunction r = new IncFunction(); |
2028 |
|
checkCompletedNormally(g, v1); |
2029 |
|
checkCompletedWithWrappedCFException(f, ex); |
2030 |
|
checkCompletedWithWrappedCFException(h, ex); |
2031 |
< |
} |
2073 |
< |
} |
2031 |
> |
}} |
2032 |
|
|
2033 |
|
public void testApplyToEither_exceptionalCompletion2() { |
2034 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2035 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2036 |
< |
|
2035 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2036 |
> |
{ |
2037 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2038 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2039 |
|
final IncFunction r = new IncFunction(); |
2048 |
|
checkCompletedNormally(f, v1); |
2049 |
|
checkCompletedWithWrappedCFException(g, ex); |
2050 |
|
checkCompletedWithWrappedCFException(h, ex); |
2051 |
< |
} |
2094 |
< |
} |
2051 |
> |
}} |
2052 |
|
|
2053 |
|
public void testApplyToEither_exceptionalCompletion3() { |
2054 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2055 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2056 |
< |
|
2055 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2056 |
> |
{ |
2057 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2058 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2059 |
|
final IncFunction r = new IncFunction(); |
2075 |
|
|
2076 |
|
checkCompletedWithWrappedCFException(g, ex); |
2077 |
|
checkCompletedNormally(f, v1); |
2078 |
< |
} |
2122 |
< |
} |
2078 |
> |
}} |
2079 |
|
|
2080 |
|
public void testApplyToEither_exceptionalCompletion4() { |
2081 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2082 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2083 |
< |
|
2082 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2083 |
> |
{ |
2084 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2085 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2086 |
|
final IncFunction r = new IncFunction(); |
2102 |
|
|
2103 |
|
checkCompletedWithWrappedCFException(f, ex); |
2104 |
|
checkCompletedNormally(g, v1); |
2105 |
< |
} |
2150 |
< |
} |
2105 |
> |
}} |
2106 |
|
|
2107 |
|
/** |
2108 |
|
* applyToEither result completes exceptionally if action does |
2110 |
|
public void testApplyToEither_actionFailed1() { |
2111 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2112 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2113 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2114 |
< |
|
2113 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2114 |
> |
{ |
2115 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2116 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2117 |
|
final FailingFunction r = new FailingFunction(); |
2122 |
|
g.complete(v2); |
2123 |
|
checkCompletedNormally(f, v1); |
2124 |
|
checkCompletedNormally(g, v2); |
2125 |
< |
} |
2171 |
< |
} |
2125 |
> |
}} |
2126 |
|
|
2127 |
|
public void testApplyToEither_actionFailed2() { |
2128 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2129 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2130 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2131 |
< |
|
2130 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2131 |
> |
{ |
2132 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2133 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2134 |
|
final FailingFunction r = new FailingFunction(); |
2139 |
|
f.complete(v1); |
2140 |
|
checkCompletedNormally(f, v1); |
2141 |
|
checkCompletedNormally(g, v2); |
2142 |
< |
} |
2189 |
< |
} |
2142 |
> |
}} |
2143 |
|
|
2144 |
|
/** |
2145 |
|
* applyToEither result completes exceptionally if either source cancelled |
2147 |
|
public void testApplyToEither_sourceCancelled1() { |
2148 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2149 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2150 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2151 |
< |
|
2150 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2151 |
> |
{ |
2152 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2153 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2154 |
|
final IncFunction r = new IncFunction(); |
2162 |
|
assertEquals(0, r.invocationCount); |
2163 |
|
checkCompletedNormally(g, v1); |
2164 |
|
checkCompletedWithWrappedCancellationException(h); |
2165 |
< |
} |
2213 |
< |
} |
2165 |
> |
}} |
2166 |
|
|
2167 |
|
public void testApplyToEither_sourceCancelled2() { |
2168 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2169 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2170 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2171 |
< |
|
2170 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2171 |
> |
{ |
2172 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2173 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2174 |
|
final IncFunction r = new IncFunction(); |
2182 |
|
assertEquals(0, r.invocationCount); |
2183 |
|
checkCompletedNormally(f, v1); |
2184 |
|
checkCompletedWithWrappedCancellationException(h); |
2185 |
< |
} |
2234 |
< |
} |
2185 |
> |
}} |
2186 |
|
|
2187 |
|
public void testApplyToEither_sourceCancelled3() { |
2188 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2189 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2190 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2191 |
< |
|
2190 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2191 |
> |
{ |
2192 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2193 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2194 |
|
final IncFunction r = new IncFunction(); |
2209 |
|
|
2210 |
|
checkCancelled(g); |
2211 |
|
checkCompletedNormally(f, v1); |
2212 |
< |
} |
2262 |
< |
} |
2212 |
> |
}} |
2213 |
|
|
2214 |
|
public void testApplyToEither_sourceCancelled4() { |
2215 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2216 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2217 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2218 |
< |
|
2217 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2218 |
> |
{ |
2219 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2220 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2221 |
|
final IncFunction r = new IncFunction(); |
2236 |
|
|
2237 |
|
checkCancelled(f); |
2238 |
|
checkCompletedNormally(g, v1); |
2239 |
< |
} |
2290 |
< |
} |
2239 |
> |
}} |
2240 |
|
|
2241 |
|
/** |
2242 |
|
* acceptEither result completes normally after normal completion |
2245 |
|
public void testAcceptEither_normalCompletion1() { |
2246 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2247 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2248 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2249 |
< |
|
2248 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2249 |
> |
{ |
2250 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2251 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2252 |
|
final IncAction r = new IncAction(); |
2260 |
|
checkCompletedNormally(f, v1); |
2261 |
|
checkCompletedNormally(g, v2); |
2262 |
|
checkCompletedNormally(h, null); |
2263 |
< |
} |
2315 |
< |
} |
2263 |
> |
}} |
2264 |
|
|
2265 |
|
public void testAcceptEither_normalCompletion2() { |
2266 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2267 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2268 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2269 |
< |
|
2268 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2269 |
> |
{ |
2270 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2271 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2272 |
|
final IncAction r = new IncAction(); |
2280 |
|
checkCompletedNormally(f, v1); |
2281 |
|
checkCompletedNormally(g, v2); |
2282 |
|
checkCompletedNormally(h, null); |
2283 |
< |
} |
2284 |
< |
} |
2283 |
> |
}} |
2284 |
> |
|
2285 |
|
public void testAcceptEither_normalCompletion3() { |
2286 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2287 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2288 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2289 |
< |
|
2288 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2289 |
> |
{ |
2290 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2291 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2292 |
|
final IncAction r = new IncAction(); |
2302 |
|
// unspecified behavior |
2303 |
|
assertTrue(Objects.equals(r.value, inc(v1)) || |
2304 |
|
Objects.equals(r.value, inc(v2))); |
2305 |
< |
} |
2358 |
< |
} |
2305 |
> |
}} |
2306 |
|
|
2307 |
|
/** |
2308 |
|
* acceptEither result completes exceptionally after exceptional |
2310 |
|
*/ |
2311 |
|
public void testAcceptEither_exceptionalCompletion1() { |
2312 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2313 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2314 |
< |
|
2313 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2314 |
> |
{ |
2315 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2316 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2317 |
|
final IncAction r = new IncAction(); |
2326 |
|
checkCompletedNormally(g, v1); |
2327 |
|
checkCompletedWithWrappedCFException(f, ex); |
2328 |
|
checkCompletedWithWrappedCFException(h, ex); |
2329 |
< |
} |
2383 |
< |
} |
2329 |
> |
}} |
2330 |
|
|
2331 |
|
public void testAcceptEither_exceptionalCompletion2() { |
2332 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2333 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2334 |
< |
|
2333 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2334 |
> |
{ |
2335 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2336 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2337 |
|
final IncAction r = new IncAction(); |
2346 |
|
checkCompletedNormally(f, v1); |
2347 |
|
checkCompletedWithWrappedCFException(g, ex); |
2348 |
|
checkCompletedWithWrappedCFException(h, ex); |
2349 |
< |
} |
2404 |
< |
} |
2349 |
> |
}} |
2350 |
|
|
2351 |
|
public void testAcceptEither_exceptionalCompletion3() { |
2352 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2353 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2354 |
< |
|
2353 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2354 |
> |
{ |
2355 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2356 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2357 |
|
final IncAction r = new IncAction(); |
2374 |
|
|
2375 |
|
checkCompletedWithWrappedCFException(g, ex); |
2376 |
|
checkCompletedNormally(f, v1); |
2377 |
< |
} |
2433 |
< |
} |
2377 |
> |
}} |
2378 |
|
|
2379 |
|
public void testAcceptEither_exceptionalCompletion4() { |
2380 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2381 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2382 |
< |
|
2381 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2382 |
> |
{ |
2383 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2384 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2385 |
|
final IncAction r = new IncAction(); |
2402 |
|
|
2403 |
|
checkCompletedWithWrappedCFException(f, ex); |
2404 |
|
checkCompletedNormally(g, v1); |
2405 |
< |
} |
2462 |
< |
} |
2405 |
> |
}} |
2406 |
|
|
2407 |
|
/** |
2408 |
|
* acceptEither result completes exceptionally if action does |
2410 |
|
public void testAcceptEither_actionFailed1() { |
2411 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2412 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2413 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2414 |
< |
|
2413 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2414 |
> |
{ |
2415 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2416 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2417 |
|
final FailingConsumer r = new FailingConsumer(); |
2422 |
|
g.complete(v2); |
2423 |
|
checkCompletedNormally(f, v1); |
2424 |
|
checkCompletedNormally(g, v2); |
2425 |
< |
} |
2483 |
< |
} |
2425 |
> |
}} |
2426 |
|
|
2427 |
|
public void testAcceptEither_actionFailed2() { |
2428 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2429 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2430 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2431 |
< |
|
2430 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2431 |
> |
{ |
2432 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2433 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2434 |
|
final FailingConsumer r = new FailingConsumer(); |
2439 |
|
f.complete(v1); |
2440 |
|
checkCompletedNormally(f, v1); |
2441 |
|
checkCompletedNormally(g, v2); |
2442 |
< |
} |
2501 |
< |
} |
2442 |
> |
}} |
2443 |
|
|
2444 |
|
/** |
2445 |
|
* acceptEither result completes exceptionally if either source cancelled |
2447 |
|
public void testAcceptEither_sourceCancelled1() { |
2448 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2449 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2450 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2451 |
< |
|
2450 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2451 |
> |
{ |
2452 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2453 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2454 |
|
final IncAction r = new IncAction(); |
2462 |
|
assertEquals(0, r.invocationCount); |
2463 |
|
checkCompletedNormally(g, v1); |
2464 |
|
checkCompletedWithWrappedCancellationException(h); |
2465 |
< |
} |
2525 |
< |
} |
2465 |
> |
}} |
2466 |
|
|
2467 |
|
public void testAcceptEither_sourceCancelled2() { |
2468 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2469 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2470 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2471 |
< |
|
2470 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2471 |
> |
{ |
2472 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2473 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2474 |
|
final IncAction r = new IncAction(); |
2482 |
|
assertEquals(0, r.invocationCount); |
2483 |
|
checkCompletedNormally(f, v1); |
2484 |
|
checkCompletedWithWrappedCancellationException(h); |
2485 |
< |
} |
2546 |
< |
} |
2485 |
> |
}} |
2486 |
|
|
2487 |
|
public void testAcceptEither_sourceCancelled3() { |
2488 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2489 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2490 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2491 |
< |
|
2490 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2491 |
> |
{ |
2492 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2493 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2494 |
|
final IncAction r = new IncAction(); |
2510 |
|
|
2511 |
|
checkCancelled(g); |
2512 |
|
checkCompletedNormally(f, v1); |
2513 |
< |
} |
2575 |
< |
} |
2513 |
> |
}} |
2514 |
|
|
2515 |
|
public void testAcceptEither_sourceCancelled4() { |
2516 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2517 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2518 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2519 |
< |
|
2518 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2519 |
> |
{ |
2520 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2521 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2522 |
|
final IncAction r = new IncAction(); |
2538 |
|
|
2539 |
|
checkCancelled(f); |
2540 |
|
checkCompletedNormally(g, v1); |
2541 |
< |
} |
2604 |
< |
} |
2541 |
> |
}} |
2542 |
|
|
2543 |
|
/** |
2544 |
|
* runAfterEither result completes normally after normal completion |
2547 |
|
public void testRunAfterEither_normalCompletion1() { |
2548 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2549 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2550 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2551 |
< |
|
2550 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2551 |
> |
{ |
2552 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2553 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2554 |
|
final Noop r = new Noop(); |
2563 |
|
checkCompletedNormally(g, v2); |
2564 |
|
checkCompletedNormally(h, null); |
2565 |
|
assertEquals(1, r.invocationCount); |
2566 |
< |
} |
2630 |
< |
} |
2566 |
> |
}} |
2567 |
|
|
2568 |
|
public void testRunAfterEither_normalCompletion2() { |
2569 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2570 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2571 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2572 |
< |
|
2571 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2572 |
> |
{ |
2573 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2574 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2575 |
|
final Noop r = new Noop(); |
2584 |
|
checkCompletedNormally(g, v2); |
2585 |
|
checkCompletedNormally(h, null); |
2586 |
|
assertEquals(1, r.invocationCount); |
2587 |
< |
} |
2588 |
< |
} |
2587 |
> |
}} |
2588 |
> |
|
2589 |
|
public void testRunAfterEither_normalCompletion3() { |
2590 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2591 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2592 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2593 |
< |
|
2592 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2593 |
> |
{ |
2594 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2595 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2596 |
|
final Noop r = new Noop(); |
2603 |
|
checkCompletedNormally(f, v1); |
2604 |
|
checkCompletedNormally(g, v2); |
2605 |
|
assertEquals(1, r.invocationCount); |
2606 |
< |
} |
2671 |
< |
} |
2606 |
> |
}} |
2607 |
|
|
2608 |
|
/** |
2609 |
|
* runAfterEither result completes exceptionally after exceptional |
2611 |
|
*/ |
2612 |
|
public void testRunAfterEither_exceptionalCompletion1() { |
2613 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2614 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2615 |
< |
|
2614 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2615 |
> |
{ |
2616 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2617 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2618 |
|
final Noop r = new Noop(); |
2627 |
|
checkCompletedNormally(g, v1); |
2628 |
|
checkCompletedWithWrappedCFException(f, ex); |
2629 |
|
checkCompletedWithWrappedCFException(h, ex); |
2630 |
< |
} |
2696 |
< |
} |
2630 |
> |
}} |
2631 |
|
|
2632 |
|
public void testRunAfterEither_exceptionalCompletion2() { |
2633 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2634 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2635 |
< |
|
2634 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2635 |
> |
{ |
2636 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2637 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2638 |
|
final Noop r = new Noop(); |
2647 |
|
checkCompletedNormally(f, v1); |
2648 |
|
checkCompletedWithWrappedCFException(g, ex); |
2649 |
|
checkCompletedWithWrappedCFException(h, ex); |
2650 |
< |
} |
2717 |
< |
} |
2650 |
> |
}} |
2651 |
|
|
2652 |
|
public void testRunAfterEither_exceptionalCompletion3() { |
2653 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2654 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2655 |
< |
|
2654 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2655 |
> |
{ |
2656 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2657 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2658 |
|
final Noop r = new Noop(); |
2674 |
|
|
2675 |
|
checkCompletedWithWrappedCFException(g, ex); |
2676 |
|
checkCompletedNormally(f, v1); |
2677 |
< |
} |
2745 |
< |
} |
2677 |
> |
}} |
2678 |
|
|
2679 |
|
public void testRunAfterEither_exceptionalCompletion4() { |
2680 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2681 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2682 |
< |
|
2681 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2682 |
> |
{ |
2683 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2684 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2685 |
|
final Noop r = new Noop(); |
2701 |
|
|
2702 |
|
checkCompletedWithWrappedCFException(f, ex); |
2703 |
|
checkCompletedNormally(g, v1); |
2704 |
< |
} |
2773 |
< |
} |
2704 |
> |
}} |
2705 |
|
|
2706 |
|
/** |
2707 |
|
* runAfterEither result completes exceptionally if action does |
2709 |
|
public void testRunAfterEither_actionFailed1() { |
2710 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2711 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2712 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2713 |
< |
|
2712 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2713 |
> |
{ |
2714 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2715 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2716 |
|
final FailingNoop r = new FailingNoop(); |
2721 |
|
g.complete(v2); |
2722 |
|
checkCompletedNormally(f, v1); |
2723 |
|
checkCompletedNormally(g, v2); |
2724 |
< |
} |
2794 |
< |
} |
2724 |
> |
}} |
2725 |
|
|
2726 |
|
public void testRunAfterEither_actionFailed2() { |
2727 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2728 |
|
for (Integer v1 : new Integer[] { 1, null }) |
2729 |
< |
for (Integer v2 : new Integer[] { 2, null }) { |
2730 |
< |
|
2729 |
> |
for (Integer v2 : new Integer[] { 2, null }) |
2730 |
> |
{ |
2731 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2732 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2733 |
|
final FailingNoop r = new FailingNoop(); |
2738 |
|
f.complete(v1); |
2739 |
|
checkCompletedNormally(f, v1); |
2740 |
|
checkCompletedNormally(g, v2); |
2741 |
< |
} |
2812 |
< |
} |
2741 |
> |
}} |
2742 |
|
|
2743 |
|
/** |
2744 |
|
* runAfterEither result completes exceptionally if either source cancelled |
2746 |
|
public void testRunAfterEither_sourceCancelled1() { |
2747 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2748 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2749 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2750 |
< |
|
2749 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2750 |
> |
{ |
2751 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2752 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2753 |
|
final Noop r = new Noop(); |
2761 |
|
assertEquals(0, r.invocationCount); |
2762 |
|
checkCompletedNormally(g, v1); |
2763 |
|
checkCompletedWithWrappedCancellationException(h); |
2764 |
< |
} |
2836 |
< |
} |
2764 |
> |
}} |
2765 |
|
|
2766 |
|
public void testRunAfterEither_sourceCancelled2() { |
2767 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2768 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2769 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2770 |
< |
|
2769 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2770 |
> |
{ |
2771 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2772 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2773 |
|
final Noop r = new Noop(); |
2781 |
|
assertEquals(0, r.invocationCount); |
2782 |
|
checkCompletedNormally(f, v1); |
2783 |
|
checkCompletedWithWrappedCancellationException(h); |
2784 |
< |
} |
2857 |
< |
} |
2784 |
> |
}} |
2785 |
|
|
2786 |
|
public void testRunAfterEither_sourceCancelled3() { |
2787 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2788 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2789 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2790 |
< |
|
2789 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2790 |
> |
{ |
2791 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2792 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2793 |
|
final Noop r = new Noop(); |
2808 |
|
|
2809 |
|
checkCancelled(g); |
2810 |
|
checkCompletedNormally(f, v1); |
2811 |
< |
} |
2885 |
< |
} |
2811 |
> |
}} |
2812 |
|
|
2813 |
|
public void testRunAfterEither_sourceCancelled4() { |
2814 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2815 |
|
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2816 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2817 |
< |
|
2816 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2817 |
> |
{ |
2818 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2819 |
|
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2820 |
|
final Noop r = new Noop(); |
2835 |
|
|
2836 |
|
checkCancelled(f); |
2837 |
|
checkCompletedNormally(g, v1); |
2838 |
< |
} |
2913 |
< |
} |
2838 |
> |
}} |
2839 |
|
|
2840 |
|
/** |
2841 |
|
* thenCompose result completes normally after normal completion of source |
2842 |
|
*/ |
2843 |
|
public void testThenCompose_normalCompletion1() { |
2844 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2845 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2846 |
< |
|
2845 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2846 |
> |
{ |
2847 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2848 |
|
final CompletableFutureInc r = new CompletableFutureInc(); |
2849 |
|
final CompletableFuture<Integer> g = f.thenCompose(r); |
2851 |
|
checkCompletedNormally(g, inc(v1)); |
2852 |
|
checkCompletedNormally(f, v1); |
2853 |
|
assertEquals(1, r.invocationCount); |
2854 |
< |
} |
2930 |
< |
} |
2854 |
> |
}} |
2855 |
|
|
2856 |
|
public void testThenCompose_normalCompletion2() { |
2857 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2858 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2859 |
< |
|
2858 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2859 |
> |
{ |
2860 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2861 |
|
final CompletableFutureInc r = new CompletableFutureInc(); |
2862 |
|
f.complete(v1); |
2864 |
|
checkCompletedNormally(g, inc(v1)); |
2865 |
|
checkCompletedNormally(f, v1); |
2866 |
|
assertEquals(1, r.invocationCount); |
2867 |
< |
} |
2944 |
< |
} |
2867 |
> |
}} |
2868 |
|
|
2869 |
|
/** |
2870 |
|
* thenCompose result completes exceptionally after exceptional |
2871 |
|
* completion of source |
2872 |
|
*/ |
2873 |
|
public void testThenCompose_exceptionalCompletion1() { |
2874 |
< |
for (ExecutionMode m : ExecutionMode.values()) { |
2875 |
< |
|
2874 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2875 |
> |
{ |
2876 |
|
final CFException ex = new CFException(); |
2877 |
|
final CompletableFutureInc r = new CompletableFutureInc(); |
2878 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2880 |
|
f.completeExceptionally(ex); |
2881 |
|
checkCompletedWithWrappedCFException(g, ex); |
2882 |
|
checkCompletedWithWrappedCFException(f, ex); |
2883 |
< |
} |
2961 |
< |
} |
2883 |
> |
}} |
2884 |
|
|
2885 |
|
public void testThenCompose_exceptionalCompletion2() { |
2886 |
< |
for (ExecutionMode m : ExecutionMode.values()) { |
2887 |
< |
|
2886 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2887 |
> |
{ |
2888 |
|
final CFException ex = new CFException(); |
2889 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2890 |
|
f.completeExceptionally(ex); |
2892 |
|
final CompletableFuture<Integer> g = f.thenCompose(r); |
2893 |
|
checkCompletedWithWrappedCFException(g, ex); |
2894 |
|
checkCompletedWithWrappedCFException(f, ex); |
2895 |
< |
} |
2974 |
< |
} |
2895 |
> |
}} |
2896 |
|
|
2897 |
|
/** |
2898 |
|
* thenCompose result completes exceptionally if action does |
2899 |
|
*/ |
2900 |
|
public void testThenCompose_actionFailed1() { |
2901 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2902 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2903 |
< |
|
2902 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2903 |
> |
{ |
2904 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2905 |
|
final FailingCompletableFutureFunction r |
2906 |
|
= new FailingCompletableFutureFunction(); |
2908 |
|
f.complete(v1); |
2909 |
|
checkCompletedWithWrappedCFException(g); |
2910 |
|
checkCompletedNormally(f, v1); |
2911 |
< |
} |
2991 |
< |
} |
2911 |
> |
}} |
2912 |
|
|
2913 |
|
public void testThenCompose_actionFailed2() { |
2914 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2915 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
2916 |
< |
|
2915 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2916 |
> |
{ |
2917 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2918 |
|
f.complete(v1); |
2919 |
|
final FailingCompletableFutureFunction r |
2921 |
|
final CompletableFuture<Integer> g = f.thenCompose(r); |
2922 |
|
checkCompletedWithWrappedCFException(g); |
2923 |
|
checkCompletedNormally(f, v1); |
2924 |
< |
} |
3005 |
< |
} |
2924 |
> |
}} |
2925 |
|
|
2926 |
|
/** |
2927 |
|
* thenCompose result completes exceptionally if source cancelled |
2928 |
|
*/ |
2929 |
|
public void testThenCompose_sourceCancelled1() { |
2930 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2931 |
< |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) { |
2932 |
< |
|
2931 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2932 |
> |
{ |
2933 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2934 |
|
final CompletableFutureInc r = new CompletableFutureInc(); |
2935 |
|
final CompletableFuture<Integer> g = f.thenCompose(r); |
2936 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
2937 |
|
checkCompletedWithWrappedCancellationException(g); |
2938 |
|
checkCancelled(f); |
2939 |
< |
} |
3021 |
< |
} |
2939 |
> |
}} |
2940 |
|
|
2941 |
|
public void testThenCompose_sourceCancelled2() { |
2942 |
|
for (ExecutionMode m : ExecutionMode.values()) |
2943 |
< |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) { |
2944 |
< |
|
2943 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2944 |
> |
{ |
2945 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2946 |
|
assertTrue(f.cancel(mayInterruptIfRunning)); |
2947 |
|
final CompletableFutureInc r = new CompletableFutureInc(); |
2948 |
|
final CompletableFuture<Integer> g = f.thenCompose(r); |
2949 |
|
checkCompletedWithWrappedCancellationException(g); |
2950 |
|
checkCancelled(f); |
2951 |
< |
} |
3034 |
< |
} |
2951 |
> |
}} |
2952 |
|
|
2953 |
|
// asyncs |
2954 |
|
|
3524 |
|
public void testWhenComplete_actionFailed() { |
3525 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
3526 |
|
for (ExecutionMode m : ExecutionMode.values()) |
3527 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
3528 |
< |
|
3527 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
3528 |
> |
{ |
3529 |
|
final AtomicInteger a = new AtomicInteger(0); |
3530 |
|
final CFException ex = new CFException(); |
3531 |
|
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
3542 |
|
checkCompletedNormally(f, v1); |
3543 |
|
checkCompletedWithWrappedCFException(g, ex); |
3544 |
|
assertEquals(1, a.get()); |
3545 |
< |
} |
3629 |
< |
} |
3545 |
> |
}} |
3546 |
|
|
3547 |
|
/** |
3548 |
|
* If a whenComplete action throws an exception when triggered by |
3552 |
|
public void testWhenComplete_actionFailedSourceFailed() { |
3553 |
|
for (boolean createIncomplete : new boolean[] { true, false }) |
3554 |
|
for (ExecutionMode m : ExecutionMode.values()) |
3555 |
< |
for (Integer v1 : new Integer[] { 1, null }) { |
3556 |
< |
|
3555 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
3556 |
> |
{ |
3557 |
|
final AtomicInteger a = new AtomicInteger(0); |
3558 |
|
final CFException ex1 = new CFException(); |
3559 |
|
final CFException ex2 = new CFException(); |
3573 |
|
checkCompletedWithWrappedCFException(f, ex1); |
3574 |
|
checkCompletedWithWrappedCFException(g, ex1); |
3575 |
|
assertEquals(1, a.get()); |
3576 |
< |
} |
3661 |
< |
} |
3576 |
> |
}} |
3577 |
|
|
3578 |
|
} |