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.153 by jsr166, Sun Jun 26 19:17:08 2016 UTC vs.
Revision 1.154 by jsr166, Sun Jun 26 19:27:42 2016 UTC

# Line 3317 | Line 3317 | public class CompletableFutureTest exten
3317          assertEquals(0, exec.count.get());
3318      }
3319  
3320 +    static class CountingRejectingExecutor implements Executor {
3321 +        final RejectedExecutionException ex = new RejectedExecutionException();
3322 +        final AtomicInteger count = new AtomicInteger(0);
3323 +        public void execute(Runnable r) {
3324 +            count.getAndIncrement();
3325 +            throw ex;
3326 +        }
3327 +    }
3328 +
3329      /**
3330       * Test submissions to an executor that rejects all tasks.
3331       */
3332      public void testRejectingExecutor() {
3324        final RejectedExecutionException ex = new RejectedExecutionException();
3325        final Executor e = (Runnable r) -> { throw ex; };
3326
3333          for (Integer v : new Integer[] { 1, null }) {
3334  
3335 +        final CountingRejectingExecutor e = new CountingRejectingExecutor();
3336 +
3337          final CompletableFuture<Integer> complete = CompletableFuture.completedFuture(v);
3338          final CompletableFuture<Integer> incomplete = new CompletableFuture<>();
3339  
# Line 3355 | Line 3363 | public class CompletableFutureTest exten
3363  
3364              for (CompletableFuture<?> future : fs) {
3365                  if (src.isDone())
3366 <                    checkCompletedWithWrappedException(future, ex);
3366 >                    checkCompletedWithWrappedException(future, e.ex);
3367                  else
3368                      checkIncomplete(future);
3369              }
# Line 3392 | Line 3400 | public class CompletableFutureTest exten
3400              fs.add(incomplete.runAfterEitherAsync(complete, () -> {}, e));
3401  
3402              for (CompletableFuture<?> future : fs)
3403 <                checkCompletedWithWrappedException(future, ex);
3403 >                checkCompletedWithWrappedException(future, e.ex);
3404              futures.addAll(fs);
3405          }
3406  
3407          incomplete.complete(v);
3408  
3409          for (CompletableFuture<?> future : futures)
3410 <            checkCompletedWithWrappedException(future, ex);
3410 >            checkCompletedWithWrappedException(future, e.ex);
3411 >
3412 >        assertEquals(futures.size(), e.count.get());
3413 >
3414          }
3415      }
3416  
# Line 3409 | Line 3420 | public class CompletableFutureTest exten
3420       * explicitly completed.
3421       */
3422      public void testRejectingExecutorNeverInvoked() {
3412        final RejectedExecutionException ex = new RejectedExecutionException();
3413        class CountingRejectingExecutor implements Executor {
3414            final AtomicInteger count = new AtomicInteger(0);
3415            public void execute(Runnable r) {
3416                count.getAndIncrement();
3417                throw ex;
3418            }
3419        }
3423          final CountingRejectingExecutor e = new CountingRejectingExecutor();
3424  
3425          for (Integer v : new Integer[] { 1, null }) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines