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.113 by jsr166, Fri Sep 4 19:57:19 2015 UTC vs.
Revision 1.117 by jsr166, Sat Sep 5 15:35:47 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 3365 | Line 3372 | public class CompletableFutureTest exten
3372       * newIncompleteFuture returns an incomplete CompletableFuture
3373       */
3374      public void testNewIncompleteFuture() {
3375 +        for (Integer v1 : new Integer[] { 1, null })
3376 +    {
3377          CompletableFuture<Integer> f = new CompletableFuture<>();
3378          CompletableFuture<Integer> g = f.newIncompleteFuture();
3379          checkIncomplete(f);
3380          checkIncomplete(g);
3381 <    }
3381 >        f.complete(v1);
3382 >        checkCompletedNormally(f, v1);
3383 >        checkIncomplete(g);
3384 >        g.complete(v1);
3385 >        checkCompletedNormally(g, v1);
3386 >        assertSame(g.getClass(), CompletableFuture.class);
3387 >    }}
3388  
3389      /**
3390       * completedStage returns a completed CompletionStage
# Line 3586 | Line 3601 | public class CompletableFutureTest exten
3601      /**
3602       * delayedExecutor returns an executor that delays submission
3603       */
3604 <    public void testDelayedExecutor() {
3604 >    public void testDelayedExecutor() throws Exception {
3605          long timeoutMillis = SMALL_DELAY_MS;
3606          Executor d = CompletableFuture.delayedExecutor(timeoutMillis,
3607                                                         MILLISECONDS);
3608          long startTime = System.nanoTime();
3609          CompletableFuture<Integer> f = CompletableFuture.supplyAsync(() -> 1, d);
3610          assertNull(f.getNow(null));
3611 <        try {
3597 <            assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS));
3598 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
3611 >        assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS));
3612          assertTrue(millisElapsedSince(startTime) > timeoutMillis/2);
3613          checkCompletedNormally(f, 1);
3614      }
# Line 3604 | Line 3617 | public class CompletableFutureTest exten
3617       * delayedExecutor for a given executor returns an executor that
3618       * delays submission
3619       */
3620 <    public void testDelayedExecutor2() {
3620 >    public void testDelayedExecutor2() throws Exception {
3621          long timeoutMillis = SMALL_DELAY_MS;
3622          Executor d = CompletableFuture.delayedExecutor(timeoutMillis,
3623                                                         MILLISECONDS,
# Line 3612 | Line 3625 | public class CompletableFutureTest exten
3625          long startTime = System.nanoTime();
3626          CompletableFuture<Integer> f = CompletableFuture.supplyAsync(() -> 1, d);
3627          assertNull(f.getNow(null));
3628 <        try {
3616 <            assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS));
3617 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
3628 >        assertEquals(1, (int) f.get(LONG_DELAY_MS, MILLISECONDS));
3629          assertTrue(millisElapsedSince(startTime) > timeoutMillis/2);
3630          checkCompletedNormally(f, 1);
3631      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines