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

Comparing jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java (file contents):
Revision 1.7 by jsr166, Fri Nov 20 16:02:10 2009 UTC vs.
Revision 1.8 by jsr166, Sat Nov 21 02:07:27 2009 UTC

# Line 14 | Line 14 | import java.util.*;
14  
15   public class ThreadPoolExecutorSubclassTest 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(ThreadPoolExecutorSubclassTest.class);
# Line 197 | Line 197 | public class ThreadPoolExecutorSubclassT
197          ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
198          try {
199              p1.execute(new ShortRunnable());
200 <            Thread.sleep(SMALL_DELAY_MS);
200 >            Thread.sleep(SMALL_DELAY_MS);
201          } finally {
202              joinPool(p1);
203          }
# Line 404 | Line 404 | public class ThreadPoolExecutorSubclassT
404       */
405      public void testIsShutdown() {
406  
407 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
407 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
408          assertFalse(p1.isShutdown());
409          try { p1.shutdown(); } catch (SecurityException ok) { return; }
410 <        assertTrue(p1.isShutdown());
410 >        assertTrue(p1.isShutdown());
411          joinPool(p1);
412      }
413  
# Line 416 | Line 416 | public class ThreadPoolExecutorSubclassT
416       *  isTerminated is false before termination, true after
417       */
418      public void testIsTerminated() throws InterruptedException {
419 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
419 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
420          assertFalse(p1.isTerminated());
421          try {
422              p1.execute(new MediumRunnable());
# Line 431 | Line 431 | public class ThreadPoolExecutorSubclassT
431       *  isTerminating is not true when running or when terminated
432       */
433      public void testIsTerminating() throws InterruptedException {
434 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
434 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
435          assertFalse(p1.isTerminating());
436          try {
437              p1.execute(new SmallRunnable());
# Line 518 | Line 518 | public class ThreadPoolExecutorSubclassT
518       *  shutDownNow returns a list containing tasks that were not run
519       */
520      public void testShutDownNow() {
521 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
521 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
522          List l;
523          try {
524              for (int i = 0; i < 5; i++)
# Line 530 | Line 530 | public class ThreadPoolExecutorSubclassT
530              } catch (SecurityException ok) { return; }
531  
532          }
533 <        assertTrue(p1.isShutdown());
534 <        assertTrue(l.size() <= 4);
533 >        assertTrue(p1.isShutdown());
534 >        assertTrue(l.size() <= 4);
535      }
536  
537      // Exception Tests
# Line 921 | Line 921 | public class ThreadPoolExecutorSubclassT
921          ThreadPoolExecutor tpe =
922              new CustomTPE(1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
923          try { tpe.shutdown(); } catch (SecurityException ok) { return; }
924 <        try {
925 <            tpe.execute(new NoOpRunnable());
926 <            shouldThrow();
927 <        } catch (RejectedExecutionException success) {}
924 >        try {
925 >            tpe.execute(new NoOpRunnable());
926 >            shouldThrow();
927 >        } catch (RejectedExecutionException success) {}
928  
929 <        joinPool(tpe);
929 >        joinPool(tpe);
930      }
931  
932      /**
# Line 937 | Line 937 | public class ThreadPoolExecutorSubclassT
937          ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
938  
939          try { p.shutdown(); } catch (SecurityException ok) { return; }
940 <        try {
940 >        try {
941              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
942 <            p.execute(r);
942 >            p.execute(r);
943              assertFalse(r.done);
944          } finally {
945              joinPool(p);
# Line 954 | Line 954 | public class ThreadPoolExecutorSubclassT
954          ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
955  
956          try { p.shutdown(); } catch (SecurityException ok) { return; }
957 <        try {
957 >        try {
958              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
959 <            p.execute(r);
959 >            p.execute(r);
960              assertFalse(r.done);
961          } finally {
962              joinPool(p);
# Line 972 | Line 972 | public class ThreadPoolExecutorSubclassT
972          ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
973  
974          try { p.shutdown(); } catch (SecurityException ok) { return; }
975 <        try {
975 >        try {
976              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
977 <            p.execute(r);
977 >            p.execute(r);
978              assertFalse(r.done);
979          } finally {
980              joinPool(p);
# Line 988 | Line 988 | public class ThreadPoolExecutorSubclassT
988      public void testExecuteNull() {
989          ThreadPoolExecutor tpe = null;
990          try {
991 <            tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
992 <            tpe.execute(null);
991 >            tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
992 >            tpe.execute(null);
993              shouldThrow();
994 <        } catch (NullPointerException success) {}
994 >        } catch (NullPointerException success) {}
995  
996 <        joinPool(tpe);
996 >        joinPool(tpe);
997      }
998  
999      /**
1000       *  setCorePoolSize of negative value throws IllegalArgumentException
1001       */
1002      public void testCorePoolSizeIllegalArgumentException() {
1003 <        ThreadPoolExecutor tpe =
1003 >        ThreadPoolExecutor tpe =
1004              new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1005 <        try {
1006 <            tpe.setCorePoolSize(-1);
1007 <            shouldThrow();
1008 <        } catch (IllegalArgumentException success) {
1005 >        try {
1006 >            tpe.setCorePoolSize(-1);
1007 >            shouldThrow();
1008 >        } catch (IllegalArgumentException success) {
1009          } finally {
1010              try { tpe.shutdown(); } catch (SecurityException ok) { return; }
1011          }
# Line 1056 | Line 1056 | public class ThreadPoolExecutorSubclassT
1056       *  when given a negative value
1057       */
1058      public void testKeepAliveTimeIllegalArgumentException() {
1059 <        ThreadPoolExecutor tpe = null;
1059 >        ThreadPoolExecutor tpe = null;
1060          try {
1061              tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1062          } catch (Exception e) {}
1063  
1064 <        try {
1064 >        try {
1065              tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS);
1066              shouldThrow();
1067          } catch (IllegalArgumentException success) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines