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.110 by dl, Fri Sep 4 10:56:14 2015 UTC vs.
Revision 1.116 by jsr166, Fri Sep 4 20:57:10 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 +            () -> f.orTimeout(1L, null),
3354 +            () -> f.completeOnTimeout(42, 1L, null),
3355          };
3356  
3357          assertThrows(NullPointerException.class, throwingActions);
# Line 3393 | Line 3400 | public class CompletableFutureTest exten
3400          Executor c = ForkJoinPool.commonPool();
3401          if (ForkJoinPool.getCommonPoolParallelism() > 1)
3402              assertSame(e, c);
3403 +        else
3404 +            assertNotSame(e, c);
3405      }
3406  
3407      /**
# Line 3547 | Line 3556 | public class CompletableFutureTest exten
3556       */
3557      public void testOrTimeout() {
3558          CompletableFuture<Integer> f = new CompletableFuture<>();
3559 <        f.orTimeout(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
3559 >        f.orTimeout(SHORT_DELAY_MS, MILLISECONDS);
3560          checkCompletedExceptionallyWithTimeout(f);
3561      }
3562  
# Line 3557 | Line 3566 | public class CompletableFutureTest exten
3566      public void testOrTimeout2() {
3567          CompletableFuture<Integer> f = new CompletableFuture<>();
3568          f.complete(1);
3569 <        f.orTimeout(SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
3569 >        f.orTimeout(SHORT_DELAY_MS, MILLISECONDS);
3570          checkCompletedNormally(f, 1);
3571      }
3572  
# Line 3566 | Line 3575 | public class CompletableFutureTest exten
3575       */
3576      public void testCompleteOnTimeout() {
3577          CompletableFuture<Integer> f = new CompletableFuture<>();
3578 <        f.completeOnTimeout(-1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
3578 >        f.completeOnTimeout(-1, SHORT_DELAY_MS, MILLISECONDS);
3579          f.join();
3580          checkCompletedNormally(f, -1);
3581      }
# Line 3577 | Line 3586 | public class CompletableFutureTest exten
3586      public void testCompleteOnTimeout2() {
3587          CompletableFuture<Integer> f = new CompletableFuture<>();
3588          f.complete(1);
3589 <        f.completeOnTimeout(-1, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
3589 >        f.completeOnTimeout(-1, SHORT_DELAY_MS, MILLISECONDS);
3590          checkCompletedNormally(f, 1);
3591      }
3592  
3593      /**
3594       * delayedExecutor returns an executor that delays submission
3595       */
3596 <    public void testDelayedExecutor() {
3596 >    public void testDelayedExecutor() throws Exception {
3597          long timeoutMillis = SMALL_DELAY_MS;
3598          Executor d = CompletableFuture.delayedExecutor(timeoutMillis,
3599                                                         MILLISECONDS);
3600          long startTime = System.nanoTime();
3601          CompletableFuture<Integer> f = CompletableFuture.supplyAsync(() -> 1, d);
3602          assertNull(f.getNow(null));
3603 <        try {
3595 <            f.get(LONG_DELAY_MS, MILLISECONDS);
3596 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
3603 >        assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS));
3604          assertTrue(millisElapsedSince(startTime) > timeoutMillis/2);
3605          checkCompletedNormally(f, 1);
3606      }
# Line 3602 | Line 3609 | public class CompletableFutureTest exten
3609       * delayedExecutor for a given executor returns an executor that
3610       * delays submission
3611       */
3612 <    public void testDelayedExecutor2() {
3612 >    public void testDelayedExecutor2() throws Exception {
3613          long timeoutMillis = SMALL_DELAY_MS;
3614          Executor d = CompletableFuture.delayedExecutor(timeoutMillis,
3615                                                         MILLISECONDS,
# Line 3610 | Line 3617 | public class CompletableFutureTest exten
3617          long startTime = System.nanoTime();
3618          CompletableFuture<Integer> f = CompletableFuture.supplyAsync(() -> 1, d);
3619          assertNull(f.getNow(null));
3620 <        try {
3614 <            f.get(LONG_DELAY_MS, MILLISECONDS);
3615 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
3620 >        assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS));
3621          assertTrue(millisElapsedSince(startTime) > timeoutMillis/2);
3622          checkCompletedNormally(f, 1);
3623      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines