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.25 by jsr166, Fri Nov 20 22:58:48 2009 UTC vs.
Revision 1.26 by jsr166, Sat Nov 21 02:07:27 2009 UTC

# Line 14 | Line 14 | import java.util.concurrent.atomic.*;
14  
15   public class ScheduledExecutorTest extends JSR166TestCase {
16      public static void main(String[] args) {
17 <        junit.textui.TestRunner.run (suite());
17 >        junit.textui.TestRunner.run (suite());
18      }
19      public static Test suite() {
20 <        return new TestSuite(ScheduledExecutorTest.class);
20 >        return new TestSuite(ScheduledExecutorTest.class);
21      }
22  
23  
# Line 142 | Line 142 | public class ScheduledExecutorTest exten
142      public void testExecuteNull() throws InterruptedException {
143          ScheduledThreadPoolExecutor se = null;
144          try {
145 <            se = new ScheduledThreadPoolExecutor(1);
146 <            se.execute(null);
145 >            se = new ScheduledThreadPoolExecutor(1);
146 >            se.execute(null);
147              shouldThrow();
148 <        } catch (NullPointerException success) {}
148 >        } catch (NullPointerException success) {}
149  
150 <        joinPool(se);
150 >        joinPool(se);
151      }
152  
153      /**
# Line 155 | Line 155 | public class ScheduledExecutorTest exten
155       */
156      public void testScheduleNull() throws InterruptedException {
157          ScheduledThreadPoolExecutor se = new ScheduledThreadPoolExecutor(1);
158 <        try {
158 >        try {
159              TrackedCallable callable = null;
160 <            Future f = se.schedule(callable, SHORT_DELAY_MS, MILLISECONDS);
160 >            Future f = se.schedule(callable, SHORT_DELAY_MS, MILLISECONDS);
161              shouldThrow();
162 <        } catch (NullPointerException success) {}
163 <        joinPool(se);
162 >        } catch (NullPointerException success) {}
163 >        joinPool(se);
164      }
165  
166      /**
# Line 325 | Line 325 | public class ScheduledExecutorTest exten
325       */
326      public void testGetThreadFactory() throws InterruptedException {
327          ThreadFactory tf = new SimpleThreadFactory();
328 <        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf);
328 >        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf);
329          assertSame(tf, p.getThreadFactory());
330          joinPool(p);
331      }
# Line 335 | Line 335 | public class ScheduledExecutorTest exten
335       */
336      public void testSetThreadFactory() throws InterruptedException {
337          ThreadFactory tf = new SimpleThreadFactory();
338 <        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
338 >        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
339          p.setThreadFactory(tf);
340          assertSame(tf, p.getThreadFactory());
341          joinPool(p);
# Line 345 | Line 345 | public class ScheduledExecutorTest exten
345       * setThreadFactory(null) throws NPE
346       */
347      public void testSetThreadFactoryNull() throws InterruptedException {
348 <        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
348 >        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
349          try {
350              p.setThreadFactory(null);
351              shouldThrow();
# Line 360 | Line 360 | public class ScheduledExecutorTest exten
360       */
361      public void testIsShutdown() {
362  
363 <        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
363 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
364          try {
365              assertFalse(p1.isShutdown());
366          }
367          finally {
368              try { p1.shutdown(); } catch (SecurityException ok) { return; }
369          }
370 <        assertTrue(p1.isShutdown());
370 >        assertTrue(p1.isShutdown());
371      }
372  
373  
# Line 375 | Line 375 | public class ScheduledExecutorTest exten
375       *   isTerminated is false before termination, true after
376       */
377      public void testIsTerminated() throws InterruptedException {
378 <        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
378 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
379          try {
380              p1.execute(new SmallRunnable());
381          } finally {
# Line 389 | Line 389 | public class ScheduledExecutorTest exten
389       *  isTerminating is not true when running or when terminated
390       */
391      public void testIsTerminating() throws InterruptedException {
392 <        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
392 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
393          assertFalse(p1.isTerminating());
394          try {
395              p1.execute(new SmallRunnable());
# Line 481 | Line 481 | public class ScheduledExecutorTest exten
481       *  shutDownNow returns a list containing tasks that were not run
482       */
483      public void testShutDownNow() throws InterruptedException {
484 <        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
484 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
485          for (int i = 0; i < 5; i++)
486              p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, MILLISECONDS);
487          List l;
# Line 490 | Line 490 | public class ScheduledExecutorTest exten
490          } catch (SecurityException ok) {
491              return;
492          }
493 <        assertTrue(p1.isShutdown());
494 <        assertTrue(l.size() > 0 && l.size() <= 5);
493 >        assertTrue(p1.isShutdown());
494 >        assertTrue(l.size() > 0 && l.size() <= 5);
495          joinPool(p1);
496      }
497  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines