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.16 by jsr166, Thu Apr 4 04:01:05 2013 UTC vs.
Revision 1.17 by jsr166, Thu Apr 4 04:16:02 2013 UTC

# Line 345 | Line 345 | public class CompletableFutureTest exten
345  
346      // Used for explicit executor tests
347      static final class ThreadExecutor implements Executor {
348 +        AtomicInteger count = new AtomicInteger(0);
349 +
350          public void execute(Runnable r) {
351 +            count.getAndIncrement();
352              new Thread(r).start();
353          }
354      }
# Line 432 | Line 435 | public class CompletableFutureTest exten
435       */
436      public void testRunAsync2() {
437          Noop r = new Noop();
438 <        CompletableFuture<Void> f = CompletableFuture.runAsync(r, new ThreadExecutor());
438 >        ThreadExecutor exec = new ThreadExecutor();
439 >        CompletableFuture<Void> f = CompletableFuture.runAsync(r, exec);
440          assertNull(f.join());
441          assertTrue(r.ran);
442          checkCompletedNormally(f, null);
443 +        assertEquals(1, exec.count.get());
444      }
445  
446      /**
# Line 452 | Line 457 | public class CompletableFutureTest exten
457       * supplyAsync completes with result of supplier
458       */
459      public void testSupplyAsync() {
460 <        CompletableFuture<Integer> f = CompletableFuture.supplyAsync(supplyOne);
460 >        CompletableFuture<Integer> f;
461 >        f = CompletableFuture.supplyAsync(supplyOne);
462          assertEquals(f.join(), one);
463 +        checkCompletedNormally(f, one);
464      }
465  
466      /**
467       * supplyAsync with executor completes with result of supplier
468       */
469      public void testSupplyAsync2() {
470 <        CompletableFuture<Integer> f = CompletableFuture.supplyAsync(supplyOne, new ThreadExecutor());
470 >        CompletableFuture<Integer> f;
471 >        f = CompletableFuture.supplyAsync(supplyOne, new ThreadExecutor());
472          assertEquals(f.join(), one);
473 +        checkCompletedNormally(f, one);
474      }
475  
476      /**
# Line 2418 | Line 2427 | public class CompletableFutureTest exten
2427          CompletableFuture<Integer> g = new CompletableFuture<Integer>();
2428          CompletableFuture<Integer> nullFuture = (CompletableFuture<Integer>)null;
2429          CompletableFuture<?> h;
2430 <        Executor exec = new ThreadExecutor();
2430 >        ThreadExecutor exec = new ThreadExecutor();
2431  
2432          Runnable[] throwingActions = {
2433              () -> { CompletableFuture.supplyAsync(null); },
# Line 2515 | Line 2524 | public class CompletableFutureTest exten
2524          };
2525  
2526          assertThrows(NullPointerException.class, throwingActions);
2527 +        assertEquals(0, exec.count.get());
2528      }
2529  
2530   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines