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.8 by jsr166, Sat Nov 21 02:07:27 2009 UTC vs.
Revision 1.9 by jsr166, Sat Nov 21 02:33:20 2009 UTC

# Line 7 | Line 7
7   */
8  
9   import java.util.concurrent.*;
10 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
11   import java.util.concurrent.locks.*;
12  
13   import junit.framework.*;
# Line 167 | Line 168 | public class ThreadPoolExecutorSubclassT
168          volatile boolean afterCalled = false;
169          volatile boolean terminatedCalled = false;
170          public CustomTPE() {
171 <            super(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>());
171 >            super(1, 1, LONG_DELAY_MS, MILLISECONDS, new SynchronousQueue<Runnable>());
172          }
173          protected void beforeExecute(Thread t, Runnable r) {
174              beforeCalled = true;
# Line 194 | Line 195 | public class ThreadPoolExecutorSubclassT
195       *  execute successfully executes a runnable
196       */
197      public void testExecute() throws InterruptedException {
198 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
198 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
199          try {
200              p1.execute(new ShortRunnable());
201              Thread.sleep(SMALL_DELAY_MS);
# Line 208 | Line 209 | public class ThreadPoolExecutorSubclassT
209       *  thread becomes active
210       */
211      public void testGetActiveCount() throws InterruptedException {
212 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
212 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
213          assertEquals(0, p2.getActiveCount());
214          p2.execute(new MediumRunnable());
215          Thread.sleep(SHORT_DELAY_MS);
# Line 220 | Line 221 | public class ThreadPoolExecutorSubclassT
221       *  prestartCoreThread starts a thread if under corePoolSize, else doesn't
222       */
223      public void testPrestartCoreThread() {
224 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
224 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
225          assertEquals(0, p2.getPoolSize());
226          assertTrue(p2.prestartCoreThread());
227          assertEquals(1, p2.getPoolSize());
# Line 235 | Line 236 | public class ThreadPoolExecutorSubclassT
236       *  prestartAllCoreThreads starts all corePoolSize threads
237       */
238      public void testPrestartAllCoreThreads() {
239 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
239 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
240          assertEquals(0, p2.getPoolSize());
241          p2.prestartAllCoreThreads();
242          assertEquals(2, p2.getPoolSize());
# Line 249 | Line 250 | public class ThreadPoolExecutorSubclassT
250       *   when tasks complete
251       */
252      public void testGetCompletedTaskCount() throws InterruptedException {
253 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
253 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
254          assertEquals(0, p2.getCompletedTaskCount());
255          p2.execute(new ShortRunnable());
256          Thread.sleep(SMALL_DELAY_MS);
# Line 262 | Line 263 | public class ThreadPoolExecutorSubclassT
263       *   getCorePoolSize returns size given in constructor if not otherwise set
264       */
265      public void testGetCorePoolSize() {
266 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
266 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
267          assertEquals(1, p1.getCorePoolSize());
268          joinPool(p1);
269      }
# Line 271 | Line 272 | public class ThreadPoolExecutorSubclassT
272       *   getKeepAliveTime returns value given in constructor if not otherwise set
273       */
274      public void testGetKeepAliveTime() {
275 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
275 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
276          assertEquals(1, p2.getKeepAliveTime(TimeUnit.SECONDS));
277          joinPool(p2);
278      }
# Line 282 | Line 283 | public class ThreadPoolExecutorSubclassT
283       */
284      public void testGetThreadFactory() {
285          ThreadFactory tf = new SimpleThreadFactory();
286 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), tf, new NoOpREHandler());
286 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), tf, new NoOpREHandler());
287          assertSame(tf, p.getThreadFactory());
288          joinPool(p);
289      }
# Line 291 | Line 292 | public class ThreadPoolExecutorSubclassT
292       * setThreadFactory sets the thread factory returned by getThreadFactory
293       */
294      public void testSetThreadFactory() {
295 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
295 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
296          ThreadFactory tf = new SimpleThreadFactory();
297          p.setThreadFactory(tf);
298          assertSame(tf, p.getThreadFactory());
# Line 303 | Line 304 | public class ThreadPoolExecutorSubclassT
304       * setThreadFactory(null) throws NPE
305       */
306      public void testSetThreadFactoryNull() {
307 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
307 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
308          try {
309              p.setThreadFactory(null);
310              shouldThrow();
# Line 318 | Line 319 | public class ThreadPoolExecutorSubclassT
319       */
320      public void testGetRejectedExecutionHandler() {
321          RejectedExecutionHandler h = new NoOpREHandler();
322 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), h);
322 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10), h);
323          assertSame(h, p.getRejectedExecutionHandler());
324          joinPool(p);
325      }
# Line 328 | Line 329 | public class ThreadPoolExecutorSubclassT
329       * getRejectedExecutionHandler
330       */
331      public void testSetRejectedExecutionHandler() {
332 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
332 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
333          RejectedExecutionHandler h = new NoOpREHandler();
334          p.setRejectedExecutionHandler(h);
335          assertSame(h, p.getRejectedExecutionHandler());
# Line 340 | Line 341 | public class ThreadPoolExecutorSubclassT
341       * setRejectedExecutionHandler(null) throws NPE
342       */
343      public void testSetRejectedExecutionHandlerNull() {
344 <        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
344 >        ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
345          try {
346              p.setRejectedExecutionHandler(null);
347              shouldThrow();
# Line 356 | Line 357 | public class ThreadPoolExecutorSubclassT
357       *   multiple threads active
358       */
359      public void testGetLargestPoolSize() throws InterruptedException {
360 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
360 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
361          assertEquals(0, p2.getLargestPoolSize());
362          p2.execute(new MediumRunnable());
363          p2.execute(new MediumRunnable());
# Line 370 | Line 371 | public class ThreadPoolExecutorSubclassT
371       *   otherwise set
372       */
373      public void testGetMaximumPoolSize() {
374 <        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
374 >        ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
375          assertEquals(2, p2.getMaximumPoolSize());
376          joinPool(p2);
377      }
# Line 380 | Line 381 | public class ThreadPoolExecutorSubclassT
381       *   become active
382       */
383      public void testGetPoolSize() {
384 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
384 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
385          assertEquals(0, p1.getPoolSize());
386          p1.execute(new MediumRunnable());
387          assertEquals(1, p1.getPoolSize());
# Line 391 | Line 392 | public class ThreadPoolExecutorSubclassT
392       *  getTaskCount increases, but doesn't overestimate, when tasks submitted
393       */
394      public void testGetTaskCount() throws InterruptedException {
395 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
395 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
396          assertEquals(0, p1.getTaskCount());
397          p1.execute(new MediumRunnable());
398          Thread.sleep(SHORT_DELAY_MS);
# Line 404 | Line 405 | public class ThreadPoolExecutorSubclassT
405       */
406      public void testIsShutdown() {
407  
408 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
408 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
409          assertFalse(p1.isShutdown());
410          try { p1.shutdown(); } catch (SecurityException ok) { return; }
411          assertTrue(p1.isShutdown());
# Line 416 | Line 417 | public class ThreadPoolExecutorSubclassT
417       *  isTerminated is false before termination, true after
418       */
419      public void testIsTerminated() throws InterruptedException {
420 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
420 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
421          assertFalse(p1.isTerminated());
422          try {
423              p1.execute(new MediumRunnable());
424          } finally {
425              try { p1.shutdown(); } catch (SecurityException ok) { return; }
426          }
427 <        assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
427 >        assertTrue(p1.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
428          assertTrue(p1.isTerminated());
429      }
430  
# Line 431 | Line 432 | public class ThreadPoolExecutorSubclassT
432       *  isTerminating is not true when running or when terminated
433       */
434      public void testIsTerminating() throws InterruptedException {
435 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
435 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
436          assertFalse(p1.isTerminating());
437          try {
438              p1.execute(new SmallRunnable());
# Line 439 | Line 440 | public class ThreadPoolExecutorSubclassT
440          } finally {
441              try { p1.shutdown(); } catch (SecurityException ok) { return; }
442          }
443 <        assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS));
443 >        assertTrue(p1.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
444          assertTrue(p1.isTerminated());
445          assertFalse(p1.isTerminating());
446      }
# Line 449 | Line 450 | public class ThreadPoolExecutorSubclassT
450       */
451      public void testGetQueue() throws InterruptedException {
452          BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
453 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q);
453 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, q);
454          FutureTask[] tasks = new FutureTask[5];
455          for (int i = 0; i < 5; i++) {
456              tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
# Line 474 | Line 475 | public class ThreadPoolExecutorSubclassT
475       */
476      public void testRemove() throws InterruptedException {
477          BlockingQueue<Runnable> q = new ArrayBlockingQueue<Runnable>(10);
478 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q);
478 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, q);
479          FutureTask[] tasks = new FutureTask[5];
480          for (int i = 0; i < 5; i++) {
481              tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
# Line 500 | Line 501 | public class ThreadPoolExecutorSubclassT
501       *   purge removes cancelled tasks from the queue
502       */
503      public void testPurge() {
504 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
504 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
505          FutureTask[] tasks = new FutureTask[5];
506          for (int i = 0; i < 5; i++) {
507              tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE);
# Line 518 | Line 519 | public class ThreadPoolExecutorSubclassT
519       *  shutDownNow returns a list containing tasks that were not run
520       */
521      public void testShutDownNow() {
522 <        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
522 >        ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
523          List l;
524          try {
525              for (int i = 0; i < 5; i++)
# Line 542 | Line 543 | public class ThreadPoolExecutorSubclassT
543       */
544      public void testConstructor1() {
545          try {
546 <            new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
546 >            new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
547              shouldThrow();
548          } catch (IllegalArgumentException success) {}
549      }
# Line 552 | Line 553 | public class ThreadPoolExecutorSubclassT
553       */
554      public void testConstructor2() {
555          try {
556 <            new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
556 >            new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
557              shouldThrow();
558          } catch (IllegalArgumentException success) {}
559      }
# Line 562 | Line 563 | public class ThreadPoolExecutorSubclassT
563       */
564      public void testConstructor3() {
565          try {
566 <            new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
566 >            new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
567              shouldThrow();
568          } catch (IllegalArgumentException success) {}
569      }
# Line 572 | Line 573 | public class ThreadPoolExecutorSubclassT
573       */
574      public void testConstructor4() {
575          try {
576 <            new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
576 >            new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
577              shouldThrow();
578          } catch (IllegalArgumentException success) {}
579      }
# Line 582 | Line 583 | public class ThreadPoolExecutorSubclassT
583       */
584      public void testConstructor5() {
585          try {
586 <            new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
586 >            new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
587              shouldThrow();
588          } catch (IllegalArgumentException success) {}
589      }
# Line 592 | Line 593 | public class ThreadPoolExecutorSubclassT
593       */
594      public void testConstructorNullPointerException() {
595          try {
596 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null);
596 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null);
597              shouldThrow();
598          } catch (NullPointerException success) {}
599      }
# Line 604 | Line 605 | public class ThreadPoolExecutorSubclassT
605       */
606      public void testConstructor6() {
607          try {
608 <            new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
608 >            new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
609              shouldThrow();
610          } catch (IllegalArgumentException success) {}
611      }
# Line 614 | Line 615 | public class ThreadPoolExecutorSubclassT
615       */
616      public void testConstructor7() {
617          try {
618 <            new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
618 >            new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
619              shouldThrow();
620          } catch (IllegalArgumentException success) {}
621      }
# Line 624 | Line 625 | public class ThreadPoolExecutorSubclassT
625       */
626      public void testConstructor8() {
627          try {
628 <            new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
628 >            new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
629              shouldThrow();
630          } catch (IllegalArgumentException success) {}
631      }
# Line 634 | Line 635 | public class ThreadPoolExecutorSubclassT
635       */
636      public void testConstructor9() {
637          try {
638 <            new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
638 >            new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
639              shouldThrow();
640          } catch (IllegalArgumentException success) {}
641      }
# Line 644 | Line 645 | public class ThreadPoolExecutorSubclassT
645       */
646      public void testConstructor10() {
647          try {
648 <            new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
648 >            new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory());
649              shouldThrow();
650          } catch (IllegalArgumentException success) {}
651      }
# Line 654 | Line 655 | public class ThreadPoolExecutorSubclassT
655       */
656      public void testConstructorNullPointerException2() {
657          try {
658 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory());
658 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new SimpleThreadFactory());
659              shouldThrow();
660          } catch (NullPointerException success) {}
661      }
# Line 665 | Line 666 | public class ThreadPoolExecutorSubclassT
666      public void testConstructorNullPointerException3() {
667          try {
668              ThreadFactory f = null;
669 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f);
669 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f);
670              shouldThrow();
671          } catch (NullPointerException success) {}
672      }
# Line 676 | Line 677 | public class ThreadPoolExecutorSubclassT
677       */
678      public void testConstructor11() {
679          try {
680 <            new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
680 >            new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
681              shouldThrow();
682          } catch (IllegalArgumentException success) {}
683      }
# Line 686 | Line 687 | public class ThreadPoolExecutorSubclassT
687       */
688      public void testConstructor12() {
689          try {
690 <            new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
690 >            new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
691              shouldThrow();
692          } catch (IllegalArgumentException success) {}
693      }
# Line 696 | Line 697 | public class ThreadPoolExecutorSubclassT
697       */
698      public void testConstructor13() {
699          try {
700 <            new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
700 >            new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
701              shouldThrow();
702          } catch (IllegalArgumentException success) {}
703      }
# Line 706 | Line 707 | public class ThreadPoolExecutorSubclassT
707       */
708      public void testConstructor14() {
709          try {
710 <            new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
710 >            new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
711              shouldThrow();
712          } catch (IllegalArgumentException success) {}
713      }
# Line 716 | Line 717 | public class ThreadPoolExecutorSubclassT
717       */
718      public void testConstructor15() {
719          try {
720 <            new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
720 >            new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new NoOpREHandler());
721              shouldThrow();
722          } catch (IllegalArgumentException success) {}
723      }
# Line 726 | Line 727 | public class ThreadPoolExecutorSubclassT
727       */
728      public void testConstructorNullPointerException4() {
729          try {
730 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new NoOpREHandler());
730 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new NoOpREHandler());
731              shouldThrow();
732          } catch (NullPointerException success) {}
733      }
# Line 737 | Line 738 | public class ThreadPoolExecutorSubclassT
738      public void testConstructorNullPointerException5() {
739          try {
740              RejectedExecutionHandler r = null;
741 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),r);
741 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),r);
742              shouldThrow();
743          } catch (NullPointerException success) {}
744      }
# Line 748 | Line 749 | public class ThreadPoolExecutorSubclassT
749       */
750      public void testConstructor16() {
751          try {
752 <            new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
752 >            new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
753              shouldThrow();
754          } catch (IllegalArgumentException success) {}
755      }
# Line 758 | Line 759 | public class ThreadPoolExecutorSubclassT
759       */
760      public void testConstructor17() {
761          try {
762 <            new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
762 >            new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
763              shouldThrow();
764          } catch (IllegalArgumentException success) {}
765      }
# Line 768 | Line 769 | public class ThreadPoolExecutorSubclassT
769       */
770      public void testConstructor18() {
771          try {
772 <            new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
772 >            new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
773              shouldThrow();
774          } catch (IllegalArgumentException success) {}
775      }
# Line 778 | Line 779 | public class ThreadPoolExecutorSubclassT
779       */
780      public void testConstructor19() {
781          try {
782 <            new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
782 >            new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
783              shouldThrow();
784          } catch (IllegalArgumentException success) {}
785      }
# Line 788 | Line 789 | public class ThreadPoolExecutorSubclassT
789       */
790      public void testConstructor20() {
791          try {
792 <            new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
792 >            new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),new NoOpREHandler());
793              shouldThrow();
794          } catch (IllegalArgumentException success) {}
795      }
# Line 798 | Line 799 | public class ThreadPoolExecutorSubclassT
799       */
800      public void testConstructorNullPointerException6() {
801          try {
802 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler());
802 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler());
803              shouldThrow();
804          } catch (NullPointerException success) {}
805      }
# Line 809 | Line 810 | public class ThreadPoolExecutorSubclassT
810      public void testConstructorNullPointerException7() {
811          try {
812              RejectedExecutionHandler r = null;
813 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),r);
813 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),new SimpleThreadFactory(),r);
814              shouldThrow();
815          } catch (NullPointerException success) {}
816      }
# Line 820 | Line 821 | public class ThreadPoolExecutorSubclassT
821      public void testConstructorNullPointerException8() {
822          try {
823              ThreadFactory f = null;
824 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f,new NoOpREHandler());
824 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10),f,new NoOpREHandler());
825              shouldThrow();
826          } catch (NullPointerException success) {}
827      }
# Line 831 | Line 832 | public class ThreadPoolExecutorSubclassT
832       *  if saturated.
833       */
834      public void testSaturatedExecute() {
835 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));
835 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));
836          try {
837  
838              for (int i = 0; i < 5; ++i) {
# Line 847 | Line 848 | public class ThreadPoolExecutorSubclassT
848       */
849      public void testSaturatedExecute2() {
850          RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy();
851 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
851 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
852          try {
853  
854              TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
# Line 873 | Line 874 | public class ThreadPoolExecutorSubclassT
874       */
875      public void testSaturatedExecute3() {
876          RejectedExecutionHandler h = new CustomTPE.DiscardPolicy();
877 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
877 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
878          try {
879  
880              TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5];
# Line 898 | Line 899 | public class ThreadPoolExecutorSubclassT
899       */
900      public void testSaturatedExecute4() {
901          RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy();
902 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
902 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
903          try {
904              p.execute(new TrackedLongRunnable());
905              TrackedLongRunnable r2 = new TrackedLongRunnable();
# Line 919 | Line 920 | public class ThreadPoolExecutorSubclassT
920       */
921      public void testRejectedExecutionExceptionOnShutdown() {
922          ThreadPoolExecutor tpe =
923 <            new CustomTPE(1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
923 >            new CustomTPE(1,1,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(1));
924          try { tpe.shutdown(); } catch (SecurityException ok) { return; }
925          try {
926              tpe.execute(new NoOpRunnable());
# Line 934 | Line 935 | public class ThreadPoolExecutorSubclassT
935       */
936      public void testCallerRunsOnShutdown() {
937          RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy();
938 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
938 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
939  
940          try { p.shutdown(); } catch (SecurityException ok) { return; }
941          try {
# Line 951 | Line 952 | public class ThreadPoolExecutorSubclassT
952       */
953      public void testDiscardOnShutdown() {
954          RejectedExecutionHandler h = new CustomTPE.DiscardPolicy();
955 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
955 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
956  
957          try { p.shutdown(); } catch (SecurityException ok) { return; }
958          try {
# Line 969 | Line 970 | public class ThreadPoolExecutorSubclassT
970       */
971      public void testDiscardOldestOnShutdown() {
972          RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy();
973 <        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
973 >        ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(1), h);
974  
975          try { p.shutdown(); } catch (SecurityException ok) { return; }
976          try {
# Line 988 | Line 989 | public class ThreadPoolExecutorSubclassT
989      public void testExecuteNull() {
990          ThreadPoolExecutor tpe = null;
991          try {
992 <            tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
992 >            tpe = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
993              tpe.execute(null);
994              shouldThrow();
995          } catch (NullPointerException success) {}
# Line 1001 | Line 1002 | public class ThreadPoolExecutorSubclassT
1002       */
1003      public void testCorePoolSizeIllegalArgumentException() {
1004          ThreadPoolExecutor tpe =
1005 <            new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1005 >            new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1006          try {
1007              tpe.setCorePoolSize(-1);
1008              shouldThrow();
# Line 1019 | Line 1020 | public class ThreadPoolExecutorSubclassT
1020      public void testMaximumPoolSizeIllegalArgumentException() {
1021          ThreadPoolExecutor tpe = null;
1022          try {
1023 <            tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1023 >            tpe = new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1024          } catch (Exception e) {}
1025          try {
1026              tpe.setMaximumPoolSize(1);
# Line 1038 | Line 1039 | public class ThreadPoolExecutorSubclassT
1039      public void testMaximumPoolSizeIllegalArgumentException2() {
1040          ThreadPoolExecutor tpe = null;
1041          try {
1042 <            tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1042 >            tpe = new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1043          } catch (Exception e) {}
1044          try {
1045              tpe.setMaximumPoolSize(-1);
# Line 1058 | Line 1059 | public class ThreadPoolExecutorSubclassT
1059      public void testKeepAliveTimeIllegalArgumentException() {
1060          ThreadPoolExecutor tpe = null;
1061          try {
1062 <            tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1062 >            tpe = new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
1063          } catch (Exception e) {}
1064  
1065          try {
1066 <            tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS);
1066 >            tpe.setKeepAliveTime(-1,MILLISECONDS);
1067              shouldThrow();
1068          } catch (IllegalArgumentException success) {
1069          } finally {
# Line 1103 | Line 1104 | public class ThreadPoolExecutorSubclassT
1104       * completed submit of callable returns result
1105       */
1106      public void testSubmitCallable() throws Exception {
1107 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1107 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1108          try {
1109              Future<String> future = e.submit(new StringTask());
1110              String result = future.get();
# Line 1117 | Line 1118 | public class ThreadPoolExecutorSubclassT
1118       * completed submit of runnable returns successfully
1119       */
1120      public void testSubmitRunnable() throws Exception {
1121 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1121 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1122          try {
1123              Future<?> future = e.submit(new NoOpRunnable());
1124              future.get();
# Line 1131 | Line 1132 | public class ThreadPoolExecutorSubclassT
1132       * completed submit of (runnable, result) returns result
1133       */
1134      public void testSubmitRunnable2() throws Exception {
1135 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1135 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1136          try {
1137              Future<String> future = e.submit(new NoOpRunnable(), TEST_STRING);
1138              String result = future.get();
# Line 1146 | Line 1147 | public class ThreadPoolExecutorSubclassT
1147       * invokeAny(null) throws NPE
1148       */
1149      public void testInvokeAny1() throws Exception {
1150 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1150 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1151          try {
1152              e.invokeAny(null);
1153              shouldThrow();
# Line 1160 | Line 1161 | public class ThreadPoolExecutorSubclassT
1161       * invokeAny(empty collection) throws IAE
1162       */
1163      public void testInvokeAny2() throws Exception {
1164 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1164 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1165          try {
1166              e.invokeAny(new ArrayList<Callable<String>>());
1167              shouldThrow();
# Line 1175 | Line 1176 | public class ThreadPoolExecutorSubclassT
1176       */
1177      public void testInvokeAny3() throws Exception {
1178          final CountDownLatch latch = new CountDownLatch(1);
1179 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1179 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1180          try {
1181              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1182              l.add(new Callable<String>() {
# Line 1199 | Line 1200 | public class ThreadPoolExecutorSubclassT
1200       * invokeAny(c) throws ExecutionException if no task completes
1201       */
1202      public void testInvokeAny4() throws Exception {
1203 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1203 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1204          try {
1205              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1206              l.add(new NPETask());
# Line 1215 | Line 1216 | public class ThreadPoolExecutorSubclassT
1216       * invokeAny(c) returns result of some task
1217       */
1218      public void testInvokeAny5() throws Exception {
1219 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1219 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1220          try {
1221              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1222              l.add(new StringTask());
# Line 1231 | Line 1232 | public class ThreadPoolExecutorSubclassT
1232       * invokeAll(null) throws NPE
1233       */
1234      public void testInvokeAll1() throws Exception {
1235 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1235 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1236          try {
1237              e.invokeAll(null);
1238              shouldThrow();
# Line 1245 | Line 1246 | public class ThreadPoolExecutorSubclassT
1246       * invokeAll(empty collection) returns empty collection
1247       */
1248      public void testInvokeAll2() throws Exception {
1249 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1249 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1250          try {
1251              List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
1252              assertTrue(r.isEmpty());
# Line 1258 | Line 1259 | public class ThreadPoolExecutorSubclassT
1259       * invokeAll(c) throws NPE if c has null elements
1260       */
1261      public void testInvokeAll3() throws Exception {
1262 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1262 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1263          try {
1264              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1265              l.add(new StringTask());
# Line 1275 | Line 1276 | public class ThreadPoolExecutorSubclassT
1276       * get of element of invokeAll(c) throws exception on failed task
1277       */
1278      public void testInvokeAll4() throws Exception {
1279 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1279 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1280          try {
1281              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1282              l.add(new NPETask());
# Line 1294 | Line 1295 | public class ThreadPoolExecutorSubclassT
1295       * invokeAll(c) returns results of all completed tasks
1296       */
1297      public void testInvokeAll5() throws Exception {
1298 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1298 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1299          try {
1300              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1301              l.add(new StringTask());
# Line 1314 | Line 1315 | public class ThreadPoolExecutorSubclassT
1315       * timed invokeAny(null) throws NPE
1316       */
1317      public void testTimedInvokeAny1() throws Exception {
1318 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1318 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1319          try {
1320 <            e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1320 >            e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
1321              shouldThrow();
1322          } catch (NullPointerException success) {
1323          } finally {
# Line 1328 | Line 1329 | public class ThreadPoolExecutorSubclassT
1329       * timed invokeAny(,,null) throws NPE
1330       */
1331      public void testTimedInvokeAnyNullTimeUnit() throws Exception {
1332 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1332 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1333          try {
1334              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1335              l.add(new StringTask());
# Line 1344 | Line 1345 | public class ThreadPoolExecutorSubclassT
1345       * timed invokeAny(empty collection) throws IAE
1346       */
1347      public void testTimedInvokeAny2() throws Exception {
1348 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1348 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1349          try {
1350 <            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1350 >            e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1351              shouldThrow();
1352          } catch (IllegalArgumentException success) {
1353          } finally {
# Line 1358 | Line 1359 | public class ThreadPoolExecutorSubclassT
1359       * timed invokeAny(c) throws NPE if c has null elements
1360       */
1361      public void testTimedInvokeAny3() throws Exception {
1362 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1362 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1363          try {
1364              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1365              l.add(new StringTask());
1366              l.add(null);
1367 <            e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1367 >            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1368              shouldThrow();
1369          } catch (NullPointerException success) {
1370          } finally {
# Line 1375 | Line 1376 | public class ThreadPoolExecutorSubclassT
1376       * timed invokeAny(c) throws ExecutionException if no task completes
1377       */
1378      public void testTimedInvokeAny4() throws Exception {
1379 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1379 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1380          try {
1381              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1382              l.add(new NPETask());
1383 <            e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1383 >            e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1384              shouldThrow();
1385          } catch (ExecutionException success) {
1386          } finally {
# Line 1391 | Line 1392 | public class ThreadPoolExecutorSubclassT
1392       * timed invokeAny(c) returns result of some task
1393       */
1394      public void testTimedInvokeAny5() throws Exception {
1395 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1395 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1396          try {
1397              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1398              l.add(new StringTask());
1399              l.add(new StringTask());
1400 <            String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1400 >            String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1401              assertSame(TEST_STRING, result);
1402          } finally {
1403              joinPool(e);
# Line 1407 | Line 1408 | public class ThreadPoolExecutorSubclassT
1408       * timed invokeAll(null) throws NPE
1409       */
1410      public void testTimedInvokeAll1() throws Exception {
1411 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1411 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1412          try {
1413 <            e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1413 >            e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
1414              shouldThrow();
1415          } catch (NullPointerException success) {
1416          } finally {
# Line 1421 | Line 1422 | public class ThreadPoolExecutorSubclassT
1422       * timed invokeAll(,,null) throws NPE
1423       */
1424      public void testTimedInvokeAllNullTimeUnit() throws Exception {
1425 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1425 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1426          try {
1427              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1428              l.add(new StringTask());
# Line 1437 | Line 1438 | public class ThreadPoolExecutorSubclassT
1438       * timed invokeAll(empty collection) returns empty collection
1439       */
1440      public void testTimedInvokeAll2() throws Exception {
1441 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1441 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1442          try {
1443 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1443 >            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1444              assertTrue(r.isEmpty());
1445          } finally {
1446              joinPool(e);
# Line 1450 | Line 1451 | public class ThreadPoolExecutorSubclassT
1451       * timed invokeAll(c) throws NPE if c has null elements
1452       */
1453      public void testTimedInvokeAll3() throws Exception {
1454 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1454 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1455          try {
1456              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1457              l.add(new StringTask());
1458              l.add(null);
1459 <            e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1459 >            e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1460              shouldThrow();
1461          } catch (NullPointerException success) {
1462          } finally {
# Line 1467 | Line 1468 | public class ThreadPoolExecutorSubclassT
1468       * get of element of invokeAll(c) throws exception on failed task
1469       */
1470      public void testTimedInvokeAll4() throws Exception {
1471 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1471 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1472          try {
1473              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1474              l.add(new NPETask());
1475 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1475 >            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1476              assertEquals(1, result.size());
1477              for (Future<String> future : result)
1478                  future.get();
# Line 1487 | Line 1488 | public class ThreadPoolExecutorSubclassT
1488       * timed invokeAll(c) returns results of all completed tasks
1489       */
1490      public void testTimedInvokeAll5() throws Exception {
1491 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1491 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1492          try {
1493              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1494              l.add(new StringTask());
1495              l.add(new StringTask());
1496 <            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS);
1496 >            List<Future<String>> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1497              assertEquals(2, result.size());
1498              for (Future<String> future : result)
1499                  assertSame(TEST_STRING, future.get());
# Line 1506 | Line 1507 | public class ThreadPoolExecutorSubclassT
1507       * timed invokeAll(c) cancels tasks not completed by timeout
1508       */
1509      public void testTimedInvokeAll6() throws Exception {
1510 <        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1510 >        ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1511          try {
1512              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
1513              l.add(new StringTask());
1514              l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING));
1515              l.add(new StringTask());
1516 <            List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS);
1516 >            List<Future<String>> result = e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS);
1517              assertEquals(3, result.size());
1518              Iterator<Future<String>> it = result.iterator();
1519              Future<String> f1 = it.next();
# Line 1533 | Line 1534 | public class ThreadPoolExecutorSubclassT
1534       * thread factory fails to create more
1535       */
1536      public void testFailingThreadFactory() throws InterruptedException {
1537 <        ExecutorService e = new CustomTPE(100, 100, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new FailingThreadFactory());
1537 >        ExecutorService e = new CustomTPE(100, 100, LONG_DELAY_MS, MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new FailingThreadFactory());
1538          try {
1539              for (int k = 0; k < 100; ++k) {
1540                  e.execute(new NoOpRunnable());
# Line 1548 | Line 1549 | public class ThreadPoolExecutorSubclassT
1549       * allowsCoreThreadTimeOut is by default false.
1550       */
1551      public void testAllowsCoreThreadTimeOut() {
1552 <        ThreadPoolExecutor tpe = new CustomTPE(2, 2, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1552 >        ThreadPoolExecutor tpe = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1553          assertFalse(tpe.allowsCoreThreadTimeOut());
1554          joinPool(tpe);
1555      }
# Line 1557 | Line 1558 | public class ThreadPoolExecutorSubclassT
1558       * allowCoreThreadTimeOut(true) causes idle threads to time out
1559       */
1560      public void testAllowCoreThreadTimeOut_true() throws InterruptedException {
1561 <        ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1561 >        ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1562          tpe.allowCoreThreadTimeOut(true);
1563          tpe.execute(new NoOpRunnable());
1564          try {
# Line 1572 | Line 1573 | public class ThreadPoolExecutorSubclassT
1573       * allowCoreThreadTimeOut(false) causes idle threads not to time out
1574       */
1575      public void testAllowCoreThreadTimeOut_false() throws InterruptedException {
1576 <        ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1576 >        ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, MILLISECONDS, new ArrayBlockingQueue<Runnable>(10));
1577          tpe.allowCoreThreadTimeOut(false);
1578          tpe.execute(new NoOpRunnable());
1579          try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines