--- jsr166/src/test/tck/ScheduledExecutorSubclassTest.java 2010/10/11 07:21:32 1.15 +++ jsr166/src/test/tck/ScheduledExecutorSubclassTest.java 2011/04/14 22:55:08 1.20 @@ -1,7 +1,7 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ import junit.framework.*; @@ -291,17 +291,17 @@ public class ScheduledExecutorSubclassTe /** * schedule callable throws RejectedExecutionException if shutdown */ - public void testSchedule3_RejectedExecutionException() { - CustomExecutor se = new CustomExecutor(1); - try { - se.shutdown(); - se.schedule(new NoOpCallable(), - MEDIUM_DELAY_MS, MILLISECONDS); - shouldThrow(); - } catch (RejectedExecutionException success) { - } catch (SecurityException ok) { - } - joinPool(se); + public void testSchedule3_RejectedExecutionException() { + CustomExecutor se = new CustomExecutor(1); + try { + se.shutdown(); + se.schedule(new NoOpCallable(), + MEDIUM_DELAY_MS, MILLISECONDS); + shouldThrow(); + } catch (RejectedExecutionException success) { + } catch (SecurityException ok) { + } + joinPool(se); } /** @@ -535,11 +535,12 @@ public class ScheduledExecutorSubclassTe try { p.execute(new CheckedRunnable() { public void realRun() throws InterruptedException { - threadStarted.countDown(); assertFalse(p.isTerminated()); + threadStarted.countDown(); done.await(); }}); assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); + assertFalse(p.isTerminating()); done.countDown(); } finally { try { p.shutdown(); } catch (SecurityException ok) { return; } @@ -559,8 +560,8 @@ public class ScheduledExecutorSubclassTe assertFalse(p.isTerminating()); p.execute(new CheckedRunnable() { public void realRun() throws InterruptedException { - threadStarted.countDown(); assertFalse(p.isTerminating()); + threadStarted.countDown(); done.await(); }}); assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); @@ -721,6 +722,8 @@ public class ScheduledExecutorSubclassTe public void testShutDown2() throws InterruptedException { CustomExecutor p = new CustomExecutor(1); p.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); + assertFalse(p.getExecuteExistingDelayedTasksAfterShutdownPolicy()); + assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy()); ScheduledFuture[] tasks = new ScheduledFuture[5]; for (int i = 0; i < tasks.length; i++) tasks[i] = p.schedule(new NoOpRunnable(), @@ -745,7 +748,11 @@ public class ScheduledExecutorSubclassTe */ public void testShutDown3() throws InterruptedException { CustomExecutor p = new CustomExecutor(1); + assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy()); + assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy()); p.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); + assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy()); + assertFalse(p.getContinueExistingPeriodicTasksAfterShutdownPolicy()); ScheduledFuture task = p.scheduleAtFixedRate(new NoOpRunnable(), 5, 5, MILLISECONDS); try { p.shutdown(); } catch (SecurityException ok) { return; } @@ -764,9 +771,11 @@ public class ScheduledExecutorSubclassTe */ public void testShutDown4() throws InterruptedException { CustomExecutor p = new CustomExecutor(1); - p.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); final CountDownLatch counter = new CountDownLatch(2); try { + p.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); + assertTrue(p.getExecuteExistingDelayedTasksAfterShutdownPolicy()); + assertTrue(p.getContinueExistingPeriodicTasksAfterShutdownPolicy()); final Runnable r = new CheckedRunnable() { public void realRun() { counter.countDown();