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.28 by jsr166, Tue Dec 1 09:48:12 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 178 | Line 178 | public class ScheduledExecutorTest exten
178          }
179  
180          joinPool(se);
181
181      }
182  
183      /**
# Line 325 | Line 324 | public class ScheduledExecutorTest exten
324       */
325      public void testGetThreadFactory() throws InterruptedException {
326          ThreadFactory tf = new SimpleThreadFactory();
327 <        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf);
327 >        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1, tf);
328          assertSame(tf, p.getThreadFactory());
329          joinPool(p);
330      }
# Line 335 | Line 334 | public class ScheduledExecutorTest exten
334       */
335      public void testSetThreadFactory() throws InterruptedException {
336          ThreadFactory tf = new SimpleThreadFactory();
337 <        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
337 >        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
338          p.setThreadFactory(tf);
339          assertSame(tf, p.getThreadFactory());
340          joinPool(p);
# Line 345 | Line 344 | public class ScheduledExecutorTest exten
344       * setThreadFactory(null) throws NPE
345       */
346      public void testSetThreadFactoryNull() throws InterruptedException {
347 <        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
347 >        ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
348          try {
349              p.setThreadFactory(null);
350              shouldThrow();
# Line 360 | Line 359 | public class ScheduledExecutorTest exten
359       */
360      public void testIsShutdown() {
361  
362 <        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
362 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
363          try {
364              assertFalse(p1.isShutdown());
365          }
366          finally {
367              try { p1.shutdown(); } catch (SecurityException ok) { return; }
368          }
369 <        assertTrue(p1.isShutdown());
369 >        assertTrue(p1.isShutdown());
370      }
371  
372  
# Line 375 | Line 374 | public class ScheduledExecutorTest exten
374       *   isTerminated is false before termination, true after
375       */
376      public void testIsTerminated() throws InterruptedException {
377 <        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
377 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
378          try {
379              p1.execute(new SmallRunnable());
380          } finally {
# Line 389 | Line 388 | public class ScheduledExecutorTest exten
388       *  isTerminating is not true when running or when terminated
389       */
390      public void testIsTerminating() throws InterruptedException {
391 <        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
391 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
392          assertFalse(p1.isTerminating());
393          try {
394              p1.execute(new SmallRunnable());
# Line 481 | Line 480 | public class ScheduledExecutorTest exten
480       *  shutDownNow returns a list containing tasks that were not run
481       */
482      public void testShutDownNow() throws InterruptedException {
483 <        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
483 >        ScheduledThreadPoolExecutor p1 = new ScheduledThreadPoolExecutor(1);
484          for (int i = 0; i < 5; i++)
485              p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, MILLISECONDS);
486          List l;
# Line 490 | Line 489 | public class ScheduledExecutorTest exten
489          } catch (SecurityException ok) {
490              return;
491          }
492 <        assertTrue(p1.isShutdown());
493 <        assertTrue(l.size() > 0 && l.size() <= 5);
492 >        assertTrue(p1.isShutdown());
493 >        assertTrue(l.size() > 0 && l.size() <= 5);
494          joinPool(p1);
495      }
496  
# Line 667 | Line 666 | public class ScheduledExecutorTest exten
666                        public String call() {
667                            try {
668                                latch.await();
669 <                          } catch (InterruptedException ok) {}
669 >                          } catch (InterruptedException quittingTime) {}
670                            return TEST_STRING;
671                        }});
672              l.add(null);
# Line 851 | Line 850 | public class ScheduledExecutorTest exten
850                        public String call() {
851                            try {
852                                latch.await();
853 <                          } catch (InterruptedException ok) {}
853 >                          } catch (InterruptedException quittingTime) {}
854                            return TEST_STRING;
855                        }});
856              l.add(null);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines