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

Comparing jsr166/src/test/tck/ScheduledExecutorSubclassTest.java (file contents):
Revision 1.48 by jsr166, Mon Oct 5 21:42:48 2015 UTC vs.
Revision 1.50 by jsr166, Mon Oct 5 22:09:02 2015 UTC

# Line 374 | Line 374 | public class ScheduledExecutorSubclassTe
374                      assertEquals(1, p.getActiveCount());
375                      done.await();
376                  }});
377 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
377 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
378              assertEquals(1, p.getActiveCount());
379              done.countDown();
380          }
# Line 439 | Line 439 | public class ScheduledExecutorSubclassTe
439                          done.await();
440                          assertEquals(THREADS, p.getLargestPoolSize());
441                      }});
442 <            assertTrue(threadsStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
442 >            assertTrue(threadsStarted.await(LONG_DELAY_MS, MILLISECONDS));
443              assertEquals(THREADS, p.getLargestPoolSize());
444              done.countDown();
445          }
# Line 462 | Line 462 | public class ScheduledExecutorSubclassTe
462                      assertEquals(1, p.getPoolSize());
463                      done.await();
464                  }});
465 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
465 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
466              assertEquals(1, p.getPoolSize());
467              done.countDown();
468          }
# Line 567 | Line 567 | public class ScheduledExecutorSubclassTe
567                      threadStarted.countDown();
568                      done.await();
569                  }});
570 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
570 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
571              assertFalse(p.isTerminating());
572              done.countDown();
573              try { p.shutdown(); } catch (SecurityException ok) { return; }
# Line 591 | Line 591 | public class ScheduledExecutorSubclassTe
591                      threadStarted.countDown();
592                      done.await();
593                  }});
594 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
594 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
595              assertFalse(p.isTerminating());
596              done.countDown();
597              try { p.shutdown(); } catch (SecurityException ok) { return; }
# Line 618 | Line 618 | public class ScheduledExecutorSubclassTe
618                      }};
619                  tasks[i] = p.schedule(r, 1, MILLISECONDS);
620              }
621 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
621 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
622              BlockingQueue<Runnable> q = p.getQueue();
623              assertTrue(q.contains(tasks[tasks.length - 1]));
624              assertFalse(q.contains(tasks[0]));
# Line 643 | Line 643 | public class ScheduledExecutorSubclassTe
643                      }};
644                  tasks[i] = p.schedule(r, 1, MILLISECONDS);
645              }
646 <            assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS));
646 >            assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS));
647              BlockingQueue<Runnable> q = p.getQueue();
648              assertFalse(p.remove((Runnable)tasks[0]));
649              assertTrue(q.contains((Runnable)tasks[4]));
# Line 662 | Line 662 | public class ScheduledExecutorSubclassTe
662       * purge removes cancelled tasks from the queue
663       */
664      public void testPurge() throws InterruptedException {
665 +        final ScheduledFuture[] tasks = new ScheduledFuture[5];
666 +        final Runnable releaser = new Runnable() { public void run() {
667 +            for (ScheduledFuture task : tasks)
668 +                if (task != null) task.cancel(true); }};
669          final CustomExecutor p = new CustomExecutor(1);
670 <        ScheduledFuture[] tasks = new ScheduledFuture[5];
671 <        for (int i = 0; i < tasks.length; i++)
672 <            tasks[i] = p.schedule(new SmallPossiblyInterruptedRunnable(),
673 <                                  LONG_DELAY_MS, MILLISECONDS);
670 <        try {
670 >        try (PoolCleaner cleaner = cleaner(p, releaser)) {
671 >            for (int i = 0; i < tasks.length; i++)
672 >                tasks[i] = p.schedule(new SmallPossiblyInterruptedRunnable(),
673 >                                      LONG_DELAY_MS, MILLISECONDS);
674              int max = tasks.length;
675              if (tasks[4].cancel(true)) --max;
676              if (tasks[3].cancel(true)) --max;
# Line 679 | Line 682 | public class ScheduledExecutorSubclassTe
682                  long count = p.getTaskCount();
683                  if (count == max)
684                      return;
685 <            } while (millisElapsedSince(startTime) < MEDIUM_DELAY_MS);
685 >            } while (millisElapsedSince(startTime) < LONG_DELAY_MS);
686              fail("Purge failed to remove cancelled tasks");
684        } finally {
685            for (ScheduledFuture task : tasks)
686                task.cancel(true);
687            joinPool(p);
687          }
688      }
689  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines