|
20 | 20 | import static java.util.Collections.emptyList;
|
21 | 21 | import static org.junit.Assert.assertEquals;
|
22 | 22 | import static org.junit.Assert.assertFalse;
|
| 23 | +import static org.junit.Assert.assertNull; |
23 | 24 | import static org.junit.Assert.assertTrue;
|
24 | 25 | import static org.junit.Assert.fail;
|
25 | 26 |
|
@@ -439,6 +440,63 @@ public void testAllOf() throws Throwable {
|
439 | 440 | trace.setExpected(expected);
|
440 | 441 | }
|
441 | 442 |
|
| 443 | + @Test |
| 444 | + public void testAllOf_varArgs() throws Throwable { |
| 445 | + DeterministicRunner r = |
| 446 | + DeterministicRunner.newRunner( |
| 447 | + () -> { |
| 448 | + trace.add("root begin"); |
| 449 | + CompletablePromise<String> f1 = Workflow.newPromise(); |
| 450 | + CompletablePromise<String> f2 = Workflow.newPromise(); |
| 451 | + CompletablePromise<String> f3 = Workflow.newPromise(); |
| 452 | + |
| 453 | + WorkflowInternal.newThread( |
| 454 | + false, |
| 455 | + () -> { |
| 456 | + trace.add("thread1 begin"); |
| 457 | + f1.complete("value1"); |
| 458 | + trace.add("thread1 done"); |
| 459 | + }) |
| 460 | + .start(); |
| 461 | + WorkflowInternal.newThread( |
| 462 | + false, |
| 463 | + () -> { |
| 464 | + trace.add("thread3 begin"); |
| 465 | + f3.complete("value3"); |
| 466 | + trace.add("thread3 done"); |
| 467 | + }) |
| 468 | + .start(); |
| 469 | + WorkflowInternal.newThread( |
| 470 | + false, |
| 471 | + () -> { |
| 472 | + trace.add("thread2 begin"); |
| 473 | + f2.complete("value2"); |
| 474 | + trace.add("thread2 done"); |
| 475 | + }) |
| 476 | + .start(); |
| 477 | + |
| 478 | + trace.add("root before allOf"); |
| 479 | + Promise<Void> all = Promise.allOf(f1, f2, f3); |
| 480 | + |
| 481 | + assertNull(all.get()); |
| 482 | + trace.add("root done"); |
| 483 | + }); |
| 484 | + r.runUntilAllBlocked(); |
| 485 | + String[] expected = |
| 486 | + new String[] { |
| 487 | + "root begin", |
| 488 | + "root before allOf", |
| 489 | + "thread1 begin", |
| 490 | + "thread1 done", |
| 491 | + "thread3 begin", |
| 492 | + "thread3 done", |
| 493 | + "thread2 begin", |
| 494 | + "thread2 done", |
| 495 | + "root done" |
| 496 | + }; |
| 497 | + trace.setExpected(expected); |
| 498 | + } |
| 499 | + |
442 | 500 | @Test
|
443 | 501 | public void testAllOf_shouldCompleteWithoutBlocking() throws Throwable {
|
444 | 502 | DeterministicRunner r =
|
|
0 commit comments