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.31 by jsr166, Sat Nov 21 02:07:27 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 387 | Line 387 | public class ThreadPoolExecutorTest exte
387              } catch (SecurityException ok) { return; }
388  
389          }
390 <        assertTrue(p1.isShutdown());
391 <        assertTrue(l.size() <= 4);
390 >        assertTrue(p1.isShutdown());
391 >        assertTrue(l.size() <= 4);
392      }
393  
394      // Exception Tests
# Line 785 | Line 785 | public class ThreadPoolExecutorTest exte
785          ThreadPoolExecutor tpe =
786              new ThreadPoolExecutor(1,1,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
787          try { tpe.shutdown(); } catch (SecurityException ok) { return; }
788 <        try {
789 <            tpe.execute(new NoOpRunnable());
790 <            shouldThrow();
791 <        } catch (RejectedExecutionException success) {}
788 >        try {
789 >            tpe.execute(new NoOpRunnable());
790 >            shouldThrow();
791 >        } catch (RejectedExecutionException success) {}
792  
793 <        joinPool(tpe);
793 >        joinPool(tpe);
794      }
795  
796      /**
# Line 801 | Line 801 | public class ThreadPoolExecutorTest exte
801          ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
802  
803          try { p.shutdown(); } catch (SecurityException ok) { return; }
804 <        try {
804 >        try {
805              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
806 <            p.execute(r);
806 >            p.execute(r);
807              assertFalse(r.done);
808          } finally {
809              joinPool(p);
# Line 818 | Line 818 | public class ThreadPoolExecutorTest exte
818          ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
819  
820          try { p.shutdown(); } catch (SecurityException ok) { return; }
821 <        try {
821 >        try {
822              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
823 <            p.execute(r);
823 >            p.execute(r);
824              assertFalse(r.done);
825          } finally {
826              joinPool(p);
# Line 836 | Line 836 | public class ThreadPoolExecutorTest exte
836          ThreadPoolExecutor p = new ThreadPoolExecutor(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
837  
838          try { p.shutdown(); } catch (SecurityException ok) { return; }
839 <        try {
839 >        try {
840              TrackedNoOpRunnable r = new TrackedNoOpRunnable();
841 <            p.execute(r);
841 >            p.execute(r);
842              assertFalse(r.done);
843          } finally {
844              joinPool(p);
# Line 852 | Line 852 | public class ThreadPoolExecutorTest exte
852      public void testExecuteNull() {
853          ThreadPoolExecutor tpe = new ThreadPoolExecutor(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
854          try {
855 <            tpe.execute(null);
855 >            tpe.execute(null);
856              shouldThrow();
857 <        } catch (NullPointerException success) {}
857 >        } catch (NullPointerException success) {}
858  
859 <        joinPool(tpe);
859 >        joinPool(tpe);
860      }
861  
862      /**
863       *  setCorePoolSize of negative value throws IllegalArgumentException
864       */
865      public void testCorePoolSizeIllegalArgumentException() {
866 <        ThreadPoolExecutor tpe =
866 >        ThreadPoolExecutor tpe =
867              new ThreadPoolExecutor(1, 2,
868                                     LONG_DELAY_MS, MILLISECONDS,
869                                     new ArrayBlockingQueue<Runnable>(10));
870 <        try {
871 <            tpe.setCorePoolSize(-1);
872 <            shouldThrow();
873 <        } catch (IllegalArgumentException success) {
870 >        try {
871 >            tpe.setCorePoolSize(-1);
872 >            shouldThrow();
873 >        } catch (IllegalArgumentException success) {
874          } finally {
875              try { tpe.shutdown(); } catch (SecurityException ok) { return; }
876          }
# Line 921 | Line 921 | public class ThreadPoolExecutorTest exte
921       *  when given a negative value
922       */
923      public void testKeepAliveTimeIllegalArgumentException() {
924 <        ThreadPoolExecutor tpe =
924 >        ThreadPoolExecutor tpe =
925              new ThreadPoolExecutor(2, 3,
926                                     LONG_DELAY_MS, MILLISECONDS,
927                                     new ArrayBlockingQueue<Runnable>(10));
928 <        try {
928 >        try {
929              tpe.setKeepAliveTime(-1,MILLISECONDS);
930              shouldThrow();
931          } catch (IllegalArgumentException success) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines