3549 |
|
*/ |
3550 |
|
public void testOrTimeout() { |
3551 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3552 |
< |
f.orTimeout(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
3552 |
> |
f.orTimeout(SHORT_DELAY_MS, MILLISECONDS); |
3553 |
|
checkCompletedExceptionallyWithTimeout(f); |
3554 |
|
} |
3555 |
|
|
3559 |
|
public void testOrTimeout2() { |
3560 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3561 |
|
f.complete(1); |
3562 |
< |
f.orTimeout(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
3562 |
> |
f.orTimeout(SHORT_DELAY_MS, MILLISECONDS); |
3563 |
|
checkCompletedNormally(f, 1); |
3564 |
|
} |
3565 |
|
|
3568 |
|
*/ |
3569 |
|
public void testCompleteOnTimeout() { |
3570 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3571 |
< |
f.completeOnTimeout(-1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
3571 |
> |
f.completeOnTimeout(-1, SHORT_DELAY_MS, MILLISECONDS); |
3572 |
|
f.join(); |
3573 |
|
checkCompletedNormally(f, -1); |
3574 |
|
} |
3579 |
|
public void testCompleteOnTimeout2() { |
3580 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3581 |
|
f.complete(1); |
3582 |
< |
f.completeOnTimeout(-1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
3582 |
> |
f.completeOnTimeout(-1, SHORT_DELAY_MS, MILLISECONDS); |
3583 |
|
checkCompletedNormally(f, 1); |
3584 |
|
} |
3585 |
|
|
3594 |
|
CompletableFuture<Integer> f = CompletableFuture.supplyAsync(() -> 1, d); |
3595 |
|
assertNull(f.getNow(null)); |
3596 |
|
try { |
3597 |
< |
f.get(LONG_DELAY_MS, MILLISECONDS); |
3597 |
> |
assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS)); |
3598 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
3599 |
|
assertTrue(millisElapsedSince(startTime) > timeoutMillis/2); |
3600 |
|
checkCompletedNormally(f, 1); |
3613 |
|
CompletableFuture<Integer> f = CompletableFuture.supplyAsync(() -> 1, d); |
3614 |
|
assertNull(f.getNow(null)); |
3615 |
|
try { |
3616 |
< |
f.get(LONG_DELAY_MS, MILLISECONDS); |
3616 |
> |
assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS)); |
3617 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
3618 |
|
assertTrue(millisElapsedSince(startTime) > timeoutMillis/2); |
3619 |
|
checkCompletedNormally(f, 1); |