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

Comparing jsr166/src/test/tck/ScheduledExecutorTest.java (file contents):
Revision 1.33 by jsr166, Mon Oct 11 07:21:32 2010 UTC vs.
Revision 1.38 by jsr166, Thu Apr 14 22:55:08 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
# Line 240 | Line 240 | public class ScheduledExecutorTest exten
240      /**
241       * schedule callable throws RejectedExecutionException if shutdown
242       */
243 <     public void testSchedule3_RejectedExecutionException() throws InterruptedException {
244 <         ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
245 <         try {
243 >    public void testSchedule3_RejectedExecutionException() throws InterruptedException {
244 >        ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
245 >        try {
246              se.shutdown();
247              se.schedule(new NoOpCallable(),
248                          MEDIUM_DELAY_MS, MILLISECONDS);
# Line 250 | Line 250 | public class ScheduledExecutorTest exten
250          } catch (RejectedExecutionException success) {
251          } catch (SecurityException ok) {
252          }
253 <         joinPool(se);
253 >        joinPool(se);
254      }
255  
256      /**
# Line 485 | Line 485 | public class ScheduledExecutorTest exten
485          try {
486              p.execute(new CheckedRunnable() {
487                  public void realRun() throws InterruptedException {
488                    threadStarted.countDown();
488                      assertFalse(p.isTerminated());
489 +                    threadStarted.countDown();
490                      done.await();
491                  }});
492              assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
493 +            assertFalse(p.isTerminating());
494              done.countDown();
495          } finally {
496              try { p.shutdown(); } catch (SecurityException ok) { return; }
# Line 509 | Line 510 | public class ScheduledExecutorTest exten
510              assertFalse(p.isTerminating());
511              p.execute(new CheckedRunnable() {
512                  public void realRun() throws InterruptedException {
512                    threadStarted.countDown();
513                      assertFalse(p.isTerminating());
514 +                    threadStarted.countDown();
515                      done.await();
516                  }});
517              assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS));
# Line 671 | Line 672 | public class ScheduledExecutorTest exten
672      public void testShutDown2() throws InterruptedException {
673          ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
674          p.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
675 +        assertFalse(p.getExecuteExistingDelayedTasksAfterShutdownPolicy());
676 +        assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy());
677          ScheduledFuture[] tasks = new ScheduledFuture[5];
678          for (int i = 0; i < tasks.length; i++)
679              tasks[i] = p.schedule(new NoOpRunnable(),
# Line 694 | Line 697 | public class ScheduledExecutorTest exten
697       */
698      public void testShutDown3() throws InterruptedException {
699          ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
700 +        assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy());
701 +        assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy());
702          p.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
703 +        assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy());
704 +        assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy());
705          ScheduledFuture task =
706              p.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, MILLISECONDS);
707          try { p.shutdown(); } catch (SecurityException ok) { return; }
# Line 713 | Line 720 | public class ScheduledExecutorTest exten
720       */
721      public void testShutDown4() throws InterruptedException {
722          ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
716        p.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
723          final CountDownLatch counter = new CountDownLatch(2);
724          try {
725 +            p.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
726 +            assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy());
727 +            assertTrue(p.getContinueExistingPeriodicTasksAfterShutdownPolicy());
728              final Runnable r = new CheckedRunnable() {
729                  public void realRun() {
730                      counter.countDown();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines