ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/CompletableFutureTest.java
(Generate patch)

Comparing jsr166/src/test/tck/CompletableFutureTest.java (file contents):
Revision 1.111 by jsr166, Fri Sep 4 13:43:25 2015 UTC vs.
Revision 1.115 by jsr166, Fri Sep 4 20:44:50 2015 UTC

# Line 3345 | Line 3345 | public class CompletableFutureTest exten
3345              () -> CompletableFuture.anyOf(null, f),
3346  
3347              () -> f.obtrudeException(null),
3348 +
3349 +            () -> CompletableFuture.delayedExecutor(1L, SECONDS, null),
3350 +            () -> CompletableFuture.delayedExecutor(1L, null, new ThreadExecutor()),
3351 +            () -> CompletableFuture.delayedExecutor(1L, null),
3352          };
3353  
3354          assertThrows(NullPointerException.class, throwingActions);
# Line 3549 | Line 3553 | public class CompletableFutureTest exten
3553       */
3554      public void testOrTimeout() {
3555          CompletableFuture<Integer> f = new CompletableFuture<>();
3556 <        f.orTimeout(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
3556 >        f.orTimeout(SHORT_DELAY_MS, MILLISECONDS);
3557          checkCompletedExceptionallyWithTimeout(f);
3558      }
3559  
# Line 3559 | Line 3563 | public class CompletableFutureTest exten
3563      public void testOrTimeout2() {
3564          CompletableFuture<Integer> f = new CompletableFuture<>();
3565          f.complete(1);
3566 <        f.orTimeout(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
3566 >        f.orTimeout(SHORT_DELAY_MS, MILLISECONDS);
3567          checkCompletedNormally(f, 1);
3568      }
3569  
# Line 3568 | Line 3572 | public class CompletableFutureTest exten
3572       */
3573      public void testCompleteOnTimeout() {
3574          CompletableFuture<Integer> f = new CompletableFuture<>();
3575 <        f.completeOnTimeout(-1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
3575 >        f.completeOnTimeout(-1, SHORT_DELAY_MS, MILLISECONDS);
3576          f.join();
3577          checkCompletedNormally(f, -1);
3578      }
# Line 3579 | Line 3583 | public class CompletableFutureTest exten
3583      public void testCompleteOnTimeout2() {
3584          CompletableFuture<Integer> f = new CompletableFuture<>();
3585          f.complete(1);
3586 <        f.completeOnTimeout(-1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
3586 >        f.completeOnTimeout(-1, SHORT_DELAY_MS, MILLISECONDS);
3587          checkCompletedNormally(f, 1);
3588      }
3589  
3590      /**
3591       * delayedExecutor returns an executor that delays submission
3592       */
3593 <    public void testDelayedExecutor() {
3593 >    public void testDelayedExecutor() throws Exception {
3594          long timeoutMillis = SMALL_DELAY_MS;
3595          Executor d = CompletableFuture.delayedExecutor(timeoutMillis,
3596                                                         MILLISECONDS);
3597          long startTime = System.nanoTime();
3598          CompletableFuture<Integer> f = CompletableFuture.supplyAsync(() -> 1, d);
3599          assertNull(f.getNow(null));
3600 <        try {
3597 <            f.get(LONG_DELAY_MS, MILLISECONDS);
3598 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
3600 >        assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS));
3601          assertTrue(millisElapsedSince(startTime) > timeoutMillis/2);
3602          checkCompletedNormally(f, 1);
3603      }
# Line 3604 | Line 3606 | public class CompletableFutureTest exten
3606       * delayedExecutor for a given executor returns an executor that
3607       * delays submission
3608       */
3609 <    public void testDelayedExecutor2() {
3609 >    public void testDelayedExecutor2() throws Exception {
3610          long timeoutMillis = SMALL_DELAY_MS;
3611          Executor d = CompletableFuture.delayedExecutor(timeoutMillis,
3612                                                         MILLISECONDS,
# Line 3612 | Line 3614 | public class CompletableFutureTest exten
3614          long startTime = System.nanoTime();
3615          CompletableFuture<Integer> f = CompletableFuture.supplyAsync(() -> 1, d);
3616          assertNull(f.getNow(null));
3617 <        try {
3616 <            f.get(LONG_DELAY_MS, MILLISECONDS);
3617 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
3617 >        assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS));
3618          assertTrue(millisElapsedSince(startTime) > timeoutMillis/2);
3619          checkCompletedNormally(f, 1);
3620      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines