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.6 by jsr166, Fri Nov 20 22:58:48 2009 UTC vs.
Revision 1.10 by jsr166, Tue Dec 1 09:48:12 2009 UTC

# Line 12 | Line 12 | import java.util.concurrent.atomic.*;
12  
13   public class ScheduledExecutorSubclassTest extends JSR166TestCase {
14      public static void main(String[] args) {
15 <        junit.textui.TestRunner.run (suite());
15 >        junit.textui.TestRunner.run (suite());
16      }
17      public static Test suite() {
18 <        return new TestSuite(ScheduledExecutorSubclassTest.class);
18 >        return new TestSuite(ScheduledExecutorSubclassTest.class);
19      }
20  
21      static class CustomTask<V> implements RunnableScheduledFuture<V> {
# Line 74 | Line 74 | public class ScheduledExecutorSubclassTe
74      }
75  
76  
77
77      /**
78       * execute successfully executes a runnable
79       */
# Line 196 | Line 195 | public class ScheduledExecutorSubclassTe
195      public void testExecuteNull() throws InterruptedException {
196          CustomExecutor se = new CustomExecutor(1);
197          try {
198 <            se.execute(null);
198 >            se.execute(null);
199              shouldThrow();
200 <        } catch (NullPointerException success) {}
201 <        joinPool(se);
200 >        } catch (NullPointerException success) {}
201 >        joinPool(se);
202      }
203  
204      /**
# Line 207 | Line 206 | public class ScheduledExecutorSubclassTe
206       */
207      public void testScheduleNull() throws InterruptedException {
208          CustomExecutor se = new CustomExecutor(1);
209 <        try {
209 >        try {
210              TrackedCallable callable = null;
211 <            Future f = se.schedule(callable, SHORT_DELAY_MS, MILLISECONDS);
211 >            Future f = se.schedule(callable, SHORT_DELAY_MS, MILLISECONDS);
212              shouldThrow();
213 <        } catch (NullPointerException success) {}
214 <        joinPool(se);
213 >        } catch (NullPointerException success) {}
214 >        joinPool(se);
215      }
216  
217      /**
# Line 313 | Line 312 | public class ScheduledExecutorSubclassTe
312       *    getCompletedTaskCount increases, but doesn't overestimate,
313       *   when tasks complete
314       */
315 <    public void testGetCompletedTaskCount()throws InterruptedException  {
315 >    public void testGetCompletedTaskCount() throws InterruptedException {
316          CustomExecutor p2 = new CustomExecutor(2);
317          assertEquals(0, p2.getCompletedTaskCount());
318          p2.execute(new SmallRunnable());
# Line 376 | Line 375 | public class ScheduledExecutorSubclassTe
375       */
376      public void testGetThreadFactory() {
377          ThreadFactory tf = new SimpleThreadFactory();
378 <        CustomExecutor p = new CustomExecutor(1, tf);
378 >        CustomExecutor p = new CustomExecutor(1, tf);
379          assertSame(tf, p.getThreadFactory());
380          joinPool(p);
381      }
# Line 386 | Line 385 | public class ScheduledExecutorSubclassTe
385       */
386      public void testSetThreadFactory() {
387          ThreadFactory tf = new SimpleThreadFactory();
388 <        CustomExecutor p = new CustomExecutor(1);
388 >        CustomExecutor p = new CustomExecutor(1);
389          p.setThreadFactory(tf);
390          assertSame(tf, p.getThreadFactory());
391          joinPool(p);
# Line 396 | Line 395 | public class ScheduledExecutorSubclassTe
395       * setThreadFactory(null) throws NPE
396       */
397      public void testSetThreadFactoryNull() {
398 <        CustomExecutor p = new CustomExecutor(1);
398 >        CustomExecutor p = new CustomExecutor(1);
399          try {
400              p.setThreadFactory(null);
401              shouldThrow();
# Line 410 | Line 409 | public class ScheduledExecutorSubclassTe
409       *   is isShutDown is false before shutdown, true after
410       */
411      public void testIsShutdown() {
412 <        CustomExecutor p1 = new CustomExecutor(1);
412 >        CustomExecutor p1 = new CustomExecutor(1);
413          try {
414              assertFalse(p1.isShutdown());
415          }
416          finally {
417              try { p1.shutdown(); } catch (SecurityException ok) { return; }
418          }
419 <        assertTrue(p1.isShutdown());
419 >        assertTrue(p1.isShutdown());
420      }
421  
422  
# Line 425 | Line 424 | public class ScheduledExecutorSubclassTe
424       *  isTerminated is false before termination, true after
425       */
426      public void testIsTerminated() throws InterruptedException {
427 <        CustomExecutor p1 = new CustomExecutor(1);
427 >        CustomExecutor p1 = new CustomExecutor(1);
428          try {
429              p1.execute(new SmallRunnable());
430          } finally {
# Line 439 | Line 438 | public class ScheduledExecutorSubclassTe
438       *  isTerminating is not true when running or when terminated
439       */
440      public void testIsTerminating() throws InterruptedException {
441 <        CustomExecutor p1 = new CustomExecutor(1);
441 >        CustomExecutor p1 = new CustomExecutor(1);
442          assertFalse(p1.isTerminating());
443          try {
444              p1.execute(new SmallRunnable());
# Line 530 | Line 529 | public class ScheduledExecutorSubclassTe
529       *  shutDownNow returns a list containing tasks that were not run
530       */
531      public void testShutDownNow() {
532 <        CustomExecutor p1 = new CustomExecutor(1);
532 >        CustomExecutor p1 = new CustomExecutor(1);
533          for (int i = 0; i < 5; i++)
534              p1.schedule(new SmallPossiblyInterruptedRunnable(), SHORT_DELAY_MS, MILLISECONDS);
535          List l;
# Line 539 | Line 538 | public class ScheduledExecutorSubclassTe
538          } catch (SecurityException ok) {
539              return;
540          }
541 <        assertTrue(p1.isShutdown());
542 <        assertTrue(l.size() > 0 && l.size() <= 5);
541 >        assertTrue(p1.isShutdown());
542 >        assertTrue(l.size() > 0 && l.size() <= 5);
543          joinPool(p1);
544      }
545  
# Line 716 | Line 715 | public class ScheduledExecutorSubclassTe
715                        public String call() {
716                            try {
717                                latch.await();
718 <                          } catch (InterruptedException ok) {}
718 >                          } catch (InterruptedException quittingTime) {}
719                            return TEST_STRING;
720                        }});
721              l.add(null);
# Line 900 | Line 899 | public class ScheduledExecutorSubclassTe
899                        public String call() {
900                            try {
901                                latch.await();
902 <                          } catch (InterruptedException ok) {}
902 >                          } catch (InterruptedException quittingTime) {}
903                            return TEST_STRING;
904                        }});
905              l.add(null);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines