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

Comparing jsr166/src/test/tck/ThreadPoolExecutorTest.java (file contents):
Revision 1.30 by jsr166, Fri Nov 20 22:58:48 2009 UTC vs.
Revision 1.32 by jsr166, Tue Dec 1 09:48:12 2009 UTC

# Line 14 | Line 14 | import java.util.*;
14  
15   public class ThreadPoolExecutorTest 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(ThreadPoolExecutorTest.class);
# Line 54 | Line 54 | public class ThreadPoolExecutorTest exte
54          ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
55          try {
56              p1.execute(new ShortRunnable());
57 <            Thread.sleep(SMALL_DELAY_MS);
57 >            Thread.sleep(SMALL_DELAY_MS);
58          } finally {
59              joinPool(p1);
60          }
# Line 261 | Line 261 | public class ThreadPoolExecutorTest exte
261       */
262      public void testIsShutdown() {
263  
264 <        ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
264 >        ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
265          assertFalse(p1.isShutdown());
266          try { p1.shutdown(); } catch (SecurityException ok) { return; }
267 <        assertTrue(p1.isShutdown());
267 >        assertTrue(p1.isShutdown());
268          joinPool(p1);
269      }
270  
# Line 273 | Line 273 | public class ThreadPoolExecutorTest exte
273       *  isTerminated is false before termination, true after
274       */
275      public void testIsTerminated() throws InterruptedException {
276 <        ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
276 >        ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
277          assertFalse(p1.isTerminated());
278          try {
279              p1.execute(new MediumRunnable());
# Line 288 | Line 288 | public class ThreadPoolExecutorTest exte
288       *  isTerminating is not true when running or when terminated
289       */
290      public void testIsTerminating() throws InterruptedException {
291 <        ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
291 >        ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
292          assertFalse(p1.isTerminating());
293          try {
294              p1.execute(new SmallRunnable());
# Line 375 | Line 375 | public class ThreadPoolExecutorTest exte
375       *  shutDownNow returns a list containing tasks that were not run
376       */
377      public void testShutDownNow() {
378 <        ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
378 >        ThreadPoolExecutor p1 = new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
379          List l;
380          try {
381              for (int i = 0; i < 5; i++)
# Line 385 | Line 385 | public class ThreadPoolExecutorTest exte
385              try {
386                  l = p1.shutdownNow();
387              } catch (SecurityException ok) { return; }
388
388          }
389 <        assertTrue(p1.isShutdown());
390 <        assertTrue(l.size() <= 4);
389 >        assertTrue(p1.isShutdown());
390 >        assertTrue(l.size() <= 4);
391      }
392  
393      // Exception Tests
# Line 785 | Line 784 | public class ThreadPoolExecutorTest exte
784          ThreadPoolExecutor tpe =
785              new ThreadPoolExecutor(1,1,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
786          try { tpe.shutdown(); } catch (SecurityException ok) { return; }
787 <        try {
788 <            tpe.execute(new NoOpRunnable());
789 <            shouldThrow();
790 <        } catch (RejectedExecutionException success) {}
787 >        try {
788 >            tpe.execute(new NoOpRunnable());
789 >            shouldThrow();
790 >        } catch (RejectedExecutionException success) {}
791  
792 <        joinPool(tpe);
792 >        joinPool(tpe);
793      }
794  
795      /**
# Line 801 | Line 800 | public class ThreadPoolExecutorTest exte
800          ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
801  
802          try { p.shutdown(); } catch (SecurityException ok) { return; }
803 <        try {
803 >        try {
804              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
805 <            p.execute(r);
805 >            p.execute(r);
806              assertFalse(r.done);
807          } finally {
808              joinPool(p);
# Line 818 | Line 817 | public class ThreadPoolExecutorTest exte
817          ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
818  
819          try { p.shutdown(); } catch (SecurityException ok) { return; }
820 <        try {
820 >        try {
821              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
822 <            p.execute(r);
822 >            p.execute(r);
823              assertFalse(r.done);
824          } finally {
825              joinPool(p);
# Line 836 | Line 835 | public class ThreadPoolExecutorTest exte
835          ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
836  
837          try { p.shutdown(); } catch (SecurityException ok) { return; }
838 <        try {
838 >        try {
839              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
840 <            p.execute(r);
840 >            p.execute(r);
841              assertFalse(r.done);
842          } finally {
843              joinPool(p);
# Line 852 | Line 851 | public class ThreadPoolExecutorTest exte
851      public void testExecuteNull() {
852          ThreadPoolExecutor tpe = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
853          try {
854 <            tpe.execute(null);
854 >            tpe.execute(null);
855              shouldThrow();
856 <        } catch (NullPointerException success) {}
856 >        } catch (NullPointerException success) {}
857  
858 <        joinPool(tpe);
858 >        joinPool(tpe);
859      }
860  
861      /**
862       *  setCorePoolSize of negative value throws IllegalArgumentException
863       */
864      public void testCorePoolSizeIllegalArgumentException() {
865 <        ThreadPoolExecutor tpe =
865 >        ThreadPoolExecutor tpe =
866              new ThreadPoolExecutor(1, 2,
867                                     LONG_DELAY_MS, MILLISECONDS,
868                                     new ArrayBlockingQueue<Runnable>(10));
869 <        try {
870 <            tpe.setCorePoolSize(-1);
871 <            shouldThrow();
872 <        } catch (IllegalArgumentException success) {
869 >        try {
870 >            tpe.setCorePoolSize(-1);
871 >            shouldThrow();
872 >        } catch (IllegalArgumentException success) {
873          } finally {
874              try { tpe.shutdown(); } catch (SecurityException ok) { return; }
875          }
# Line 921 | Line 920 | public class ThreadPoolExecutorTest exte
920       *  when given a negative value
921       */
922      public void testKeepAliveTimeIllegalArgumentException() {
923 <        ThreadPoolExecutor tpe =
923 >        ThreadPoolExecutor tpe =
924              new ThreadPoolExecutor(2, 3,
925                                     LONG_DELAY_MS, MILLISECONDS,
926                                     new ArrayBlockingQueue<Runnable>(10));
927 <        try {
927 >        try {
928              tpe.setKeepAliveTime(-1,MILLISECONDS);
929              shouldThrow();
930          } catch (IllegalArgumentException success) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines