--- jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java 2009/11/21 02:07:27 1.8 +++ jsr166/src/test/tck/ThreadPoolExecutorSubclassTest.java 2009/11/21 20:17:40 1.15 @@ -7,6 +7,7 @@ */ import java.util.concurrent.*; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import java.util.concurrent.locks.*; import junit.framework.*; @@ -167,7 +168,7 @@ public class ThreadPoolExecutorSubclassT volatile boolean afterCalled = false; volatile boolean terminatedCalled = false; public CustomTPE() { - super(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new SynchronousQueue()); + super(1, 1, LONG_DELAY_MS, MILLISECONDS, new SynchronousQueue()); } protected void beforeExecute(Thread t, Runnable r) { beforeCalled = true; @@ -194,7 +195,7 @@ public class ThreadPoolExecutorSubclassT * execute successfully executes a runnable */ public void testExecute() throws InterruptedException { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { p1.execute(new ShortRunnable()); Thread.sleep(SMALL_DELAY_MS); @@ -208,7 +209,7 @@ public class ThreadPoolExecutorSubclassT * thread becomes active */ public void testGetActiveCount() throws InterruptedException { - ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(0, p2.getActiveCount()); p2.execute(new MediumRunnable()); Thread.sleep(SHORT_DELAY_MS); @@ -220,7 +221,7 @@ public class ThreadPoolExecutorSubclassT * prestartCoreThread starts a thread if under corePoolSize, else doesn't */ public void testPrestartCoreThread() { - ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(0, p2.getPoolSize()); assertTrue(p2.prestartCoreThread()); assertEquals(1, p2.getPoolSize()); @@ -235,7 +236,7 @@ public class ThreadPoolExecutorSubclassT * prestartAllCoreThreads starts all corePoolSize threads */ public void testPrestartAllCoreThreads() { - ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(0, p2.getPoolSize()); p2.prestartAllCoreThreads(); assertEquals(2, p2.getPoolSize()); @@ -249,7 +250,7 @@ public class ThreadPoolExecutorSubclassT * when tasks complete */ public void testGetCompletedTaskCount() throws InterruptedException { - ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(0, p2.getCompletedTaskCount()); p2.execute(new ShortRunnable()); Thread.sleep(SMALL_DELAY_MS); @@ -262,7 +263,7 @@ public class ThreadPoolExecutorSubclassT * getCorePoolSize returns size given in constructor if not otherwise set */ public void testGetCorePoolSize() { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(1, p1.getCorePoolSize()); joinPool(p1); } @@ -271,7 +272,7 @@ public class ThreadPoolExecutorSubclassT * getKeepAliveTime returns value given in constructor if not otherwise set */ public void testGetKeepAliveTime() { - ThreadPoolExecutor p2 = new CustomTPE(2, 2, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p2 = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(1, p2.getKeepAliveTime(TimeUnit.SECONDS)); joinPool(p2); } @@ -282,7 +283,7 @@ public class ThreadPoolExecutorSubclassT */ public void testGetThreadFactory() { ThreadFactory tf = new SimpleThreadFactory(); - ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10), tf, new NoOpREHandler()); + ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10), tf, new NoOpREHandler()); assertSame(tf, p.getThreadFactory()); joinPool(p); } @@ -291,7 +292,7 @@ public class ThreadPoolExecutorSubclassT * setThreadFactory sets the thread factory returned by getThreadFactory */ public void testSetThreadFactory() { - ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); ThreadFactory tf = new SimpleThreadFactory(); p.setThreadFactory(tf); assertSame(tf, p.getThreadFactory()); @@ -303,7 +304,7 @@ public class ThreadPoolExecutorSubclassT * setThreadFactory(null) throws NPE */ public void testSetThreadFactoryNull() { - ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { p.setThreadFactory(null); shouldThrow(); @@ -318,7 +319,7 @@ public class ThreadPoolExecutorSubclassT */ public void testGetRejectedExecutionHandler() { RejectedExecutionHandler h = new NoOpREHandler(); - ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10), h); + ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10), h); assertSame(h, p.getRejectedExecutionHandler()); joinPool(p); } @@ -328,7 +329,7 @@ public class ThreadPoolExecutorSubclassT * getRejectedExecutionHandler */ public void testSetRejectedExecutionHandler() { - ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); RejectedExecutionHandler h = new NoOpREHandler(); p.setRejectedExecutionHandler(h); assertSame(h, p.getRejectedExecutionHandler()); @@ -340,7 +341,7 @@ public class ThreadPoolExecutorSubclassT * setRejectedExecutionHandler(null) throws NPE */ public void testSetRejectedExecutionHandlerNull() { - ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { p.setRejectedExecutionHandler(null); shouldThrow(); @@ -356,7 +357,7 @@ public class ThreadPoolExecutorSubclassT * multiple threads active */ public void testGetLargestPoolSize() throws InterruptedException { - ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(0, p2.getLargestPoolSize()); p2.execute(new MediumRunnable()); p2.execute(new MediumRunnable()); @@ -370,7 +371,7 @@ public class ThreadPoolExecutorSubclassT * otherwise set */ public void testGetMaximumPoolSize() { - ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p2 = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(2, p2.getMaximumPoolSize()); joinPool(p2); } @@ -380,7 +381,7 @@ public class ThreadPoolExecutorSubclassT * become active */ public void testGetPoolSize() { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(0, p1.getPoolSize()); p1.execute(new MediumRunnable()); assertEquals(1, p1.getPoolSize()); @@ -391,7 +392,7 @@ public class ThreadPoolExecutorSubclassT * getTaskCount increases, but doesn't overestimate, when tasks submitted */ public void testGetTaskCount() throws InterruptedException { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertEquals(0, p1.getTaskCount()); p1.execute(new MediumRunnable()); Thread.sleep(SHORT_DELAY_MS); @@ -404,7 +405,7 @@ public class ThreadPoolExecutorSubclassT */ public void testIsShutdown() { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertFalse(p1.isShutdown()); try { p1.shutdown(); } catch (SecurityException ok) { return; } assertTrue(p1.isShutdown()); @@ -416,14 +417,14 @@ public class ThreadPoolExecutorSubclassT * isTerminated is false before termination, true after */ public void testIsTerminated() throws InterruptedException { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertFalse(p1.isTerminated()); try { p1.execute(new MediumRunnable()); } finally { try { p1.shutdown(); } catch (SecurityException ok) { return; } } - assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); + assertTrue(p1.awaitTermination(LONG_DELAY_MS, MILLISECONDS)); assertTrue(p1.isTerminated()); } @@ -431,7 +432,7 @@ public class ThreadPoolExecutorSubclassT * isTerminating is not true when running or when terminated */ public void testIsTerminating() throws InterruptedException { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); assertFalse(p1.isTerminating()); try { p1.execute(new SmallRunnable()); @@ -439,7 +440,7 @@ public class ThreadPoolExecutorSubclassT } finally { try { p1.shutdown(); } catch (SecurityException ok) { return; } } - assertTrue(p1.awaitTermination(LONG_DELAY_MS, TimeUnit.MILLISECONDS)); + assertTrue(p1.awaitTermination(LONG_DELAY_MS, MILLISECONDS)); assertTrue(p1.isTerminated()); assertFalse(p1.isTerminating()); } @@ -449,7 +450,7 @@ public class ThreadPoolExecutorSubclassT */ public void testGetQueue() throws InterruptedException { BlockingQueue q = new ArrayBlockingQueue(10); - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, q); FutureTask[] tasks = new FutureTask[5]; for (int i = 0; i < 5; i++) { tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); @@ -474,7 +475,7 @@ public class ThreadPoolExecutorSubclassT */ public void testRemove() throws InterruptedException { BlockingQueue q = new ArrayBlockingQueue(10); - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, q); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, q); FutureTask[] tasks = new FutureTask[5]; for (int i = 0; i < 5; i++) { tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); @@ -500,7 +501,7 @@ public class ThreadPoolExecutorSubclassT * purge removes cancelled tasks from the queue */ public void testPurge() { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); FutureTask[] tasks = new FutureTask[5]; for (int i = 0; i < 5; i++) { tasks[i] = new FutureTask(new MediumPossiblyInterruptedRunnable(), Boolean.TRUE); @@ -518,7 +519,7 @@ public class ThreadPoolExecutorSubclassT * shutDownNow returns a list containing tasks that were not run */ public void testShutDownNow() { - ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor p1 = new CustomTPE(1, 1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); List l; try { for (int i = 0; i < 5; i++) @@ -542,7 +543,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor1() { try { - new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -552,7 +553,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor2() { try { - new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -562,7 +563,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor3() { try { - new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -572,7 +573,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor4() { try { - new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -582,7 +583,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor5() { try { - new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -592,7 +593,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructorNullPointerException() { try { - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null); shouldThrow(); } catch (NullPointerException success) {} } @@ -604,7 +605,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor6() { try { - new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); + new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -614,7 +615,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor7() { try { - new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); + new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -624,7 +625,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor8() { try { - new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); + new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -634,7 +635,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor9() { try { - new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); + new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -644,7 +645,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor10() { try { - new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); + new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -654,7 +655,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructorNullPointerException2() { try { - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory()); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new SimpleThreadFactory()); shouldThrow(); } catch (NullPointerException success) {} } @@ -665,7 +666,7 @@ public class ThreadPoolExecutorSubclassT public void testConstructorNullPointerException3() { try { ThreadFactory f = null; - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),f); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10),f); shouldThrow(); } catch (NullPointerException success) {} } @@ -676,7 +677,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor11() { try { - new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); + new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -686,7 +687,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor12() { try { - new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); + new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -696,7 +697,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor13() { try { - new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); + new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -706,7 +707,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor14() { try { - new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); + new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -716,7 +717,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor15() { try { - new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); + new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -726,7 +727,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructorNullPointerException4() { try { - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new NoOpREHandler()); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new NoOpREHandler()); shouldThrow(); } catch (NullPointerException success) {} } @@ -737,7 +738,7 @@ public class ThreadPoolExecutorSubclassT public void testConstructorNullPointerException5() { try { RejectedExecutionHandler r = null; - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),r); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10),r); shouldThrow(); } catch (NullPointerException success) {} } @@ -748,7 +749,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor16() { try { - new CustomTPE(-1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); + new CustomTPE(-1,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -758,7 +759,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor17() { try { - new CustomTPE(1,-1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); + new CustomTPE(1,-1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -768,7 +769,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor18() { try { - new CustomTPE(1,0,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); + new CustomTPE(1,0,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -778,7 +779,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor19() { try { - new CustomTPE(1,2,-1L,TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); + new CustomTPE(1,2,-1L,MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -788,7 +789,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructor20() { try { - new CustomTPE(2,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); + new CustomTPE(2,1,LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10),new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -798,7 +799,7 @@ public class ThreadPoolExecutorSubclassT */ public void testConstructorNullPointerException6() { try { - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler()); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,null,new SimpleThreadFactory(),new NoOpREHandler()); shouldThrow(); } catch (NullPointerException success) {} } @@ -809,7 +810,7 @@ public class ThreadPoolExecutorSubclassT public void testConstructorNullPointerException7() { try { RejectedExecutionHandler r = null; - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),new SimpleThreadFactory(),r); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10),new SimpleThreadFactory(),r); shouldThrow(); } catch (NullPointerException success) {} } @@ -820,7 +821,7 @@ public class ThreadPoolExecutorSubclassT public void testConstructorNullPointerException8() { try { ThreadFactory f = null; - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10),f,new NoOpREHandler()); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10),f,new NoOpREHandler()); shouldThrow(); } catch (NullPointerException success) {} } @@ -831,7 +832,7 @@ public class ThreadPoolExecutorSubclassT * if saturated. */ public void testSaturatedExecute() { - ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1)); + ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(1)); try { for (int i = 0; i < 5; ++i) { @@ -847,7 +848,7 @@ public class ThreadPoolExecutorSubclassT */ public void testSaturatedExecute2() { RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy(); - ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); + ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(1), h); try { TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; @@ -873,7 +874,7 @@ public class ThreadPoolExecutorSubclassT */ public void testSaturatedExecute3() { RejectedExecutionHandler h = new CustomTPE.DiscardPolicy(); - ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); + ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(1), h); try { TrackedNoOpRunnable[] tasks = new TrackedNoOpRunnable[5]; @@ -898,7 +899,7 @@ public class ThreadPoolExecutorSubclassT */ public void testSaturatedExecute4() { RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy(); - ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); + ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(1), h); try { p.execute(new TrackedLongRunnable()); TrackedLongRunnable r2 = new TrackedLongRunnable(); @@ -919,7 +920,7 @@ public class ThreadPoolExecutorSubclassT */ public void testRejectedExecutionExceptionOnShutdown() { ThreadPoolExecutor tpe = - new CustomTPE(1,1,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(1)); + new CustomTPE(1,1,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(1)); try { tpe.shutdown(); } catch (SecurityException ok) { return; } try { tpe.execute(new NoOpRunnable()); @@ -934,7 +935,7 @@ public class ThreadPoolExecutorSubclassT */ public void testCallerRunsOnShutdown() { RejectedExecutionHandler h = new CustomTPE.CallerRunsPolicy(); - ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); + ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(1), h); try { p.shutdown(); } catch (SecurityException ok) { return; } try { @@ -951,7 +952,7 @@ public class ThreadPoolExecutorSubclassT */ public void testDiscardOnShutdown() { RejectedExecutionHandler h = new CustomTPE.DiscardPolicy(); - ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); + ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(1), h); try { p.shutdown(); } catch (SecurityException ok) { return; } try { @@ -969,7 +970,7 @@ public class ThreadPoolExecutorSubclassT */ public void testDiscardOldestOnShutdown() { RejectedExecutionHandler h = new CustomTPE.DiscardOldestPolicy(); - ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(1), h); + ThreadPoolExecutor p = new CustomTPE(1,1, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(1), h); try { p.shutdown(); } catch (SecurityException ok) { return; } try { @@ -988,7 +989,7 @@ public class ThreadPoolExecutorSubclassT public void testExecuteNull() { ThreadPoolExecutor tpe = null; try { - tpe = new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); + tpe = new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10)); tpe.execute(null); shouldThrow(); } catch (NullPointerException success) {} @@ -1001,7 +1002,7 @@ public class ThreadPoolExecutorSubclassT */ public void testCorePoolSizeIllegalArgumentException() { ThreadPoolExecutor tpe = - new CustomTPE(1,2,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); + new CustomTPE(1,2,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10)); try { tpe.setCorePoolSize(-1); shouldThrow(); @@ -1017,10 +1018,8 @@ public class ThreadPoolExecutorSubclassT * given a value less the core pool size */ public void testMaximumPoolSizeIllegalArgumentException() { - ThreadPoolExecutor tpe = null; - try { - tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch (Exception e) {} + ThreadPoolExecutor tpe = + new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10)); try { tpe.setMaximumPoolSize(1); shouldThrow(); @@ -1036,10 +1035,8 @@ public class ThreadPoolExecutorSubclassT * if given a negative value */ public void testMaximumPoolSizeIllegalArgumentException2() { - ThreadPoolExecutor tpe = null; - try { - tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch (Exception e) {} + ThreadPoolExecutor tpe = + new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10)); try { tpe.setMaximumPoolSize(-1); shouldThrow(); @@ -1056,13 +1053,11 @@ public class ThreadPoolExecutorSubclassT * when given a negative value */ public void testKeepAliveTimeIllegalArgumentException() { - ThreadPoolExecutor tpe = null; - try { - tpe = new CustomTPE(2,3,LONG_DELAY_MS, TimeUnit.MILLISECONDS,new ArrayBlockingQueue(10)); - } catch (Exception e) {} + ThreadPoolExecutor tpe = + new CustomTPE(2,3,LONG_DELAY_MS, MILLISECONDS,new ArrayBlockingQueue(10)); try { - tpe.setKeepAliveTime(-1,TimeUnit.MILLISECONDS); + tpe.setKeepAliveTime(-1,MILLISECONDS); shouldThrow(); } catch (IllegalArgumentException success) { } finally { @@ -1103,7 +1098,7 @@ public class ThreadPoolExecutorSubclassT * completed submit of callable returns result */ public void testSubmitCallable() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { Future future = e.submit(new StringTask()); String result = future.get(); @@ -1117,7 +1112,7 @@ public class ThreadPoolExecutorSubclassT * completed submit of runnable returns successfully */ public void testSubmitRunnable() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { Future future = e.submit(new NoOpRunnable()); future.get(); @@ -1131,7 +1126,7 @@ public class ThreadPoolExecutorSubclassT * completed submit of (runnable, result) returns result */ public void testSubmitRunnable2() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { Future future = e.submit(new NoOpRunnable(), TEST_STRING); String result = future.get(); @@ -1146,7 +1141,7 @@ public class ThreadPoolExecutorSubclassT * invokeAny(null) throws NPE */ public void testInvokeAny1() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { e.invokeAny(null); shouldThrow(); @@ -1160,7 +1155,7 @@ public class ThreadPoolExecutorSubclassT * invokeAny(empty collection) throws IAE */ public void testInvokeAny2() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { e.invokeAny(new ArrayList>()); shouldThrow(); @@ -1175,7 +1170,7 @@ public class ThreadPoolExecutorSubclassT */ public void testInvokeAny3() throws Exception { final CountDownLatch latch = new CountDownLatch(1); - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new Callable() { @@ -1199,13 +1194,14 @@ public class ThreadPoolExecutorSubclassT * invokeAny(c) throws ExecutionException if no task completes */ public void testInvokeAny4() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new NPETask()); e.invokeAny(l); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } finally { joinPool(e); } @@ -1215,7 +1211,7 @@ public class ThreadPoolExecutorSubclassT * invokeAny(c) returns result of some task */ public void testInvokeAny5() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); @@ -1231,7 +1227,7 @@ public class ThreadPoolExecutorSubclassT * invokeAll(null) throws NPE */ public void testInvokeAll1() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { e.invokeAll(null); shouldThrow(); @@ -1245,7 +1241,7 @@ public class ThreadPoolExecutorSubclassT * invokeAll(empty collection) returns empty collection */ public void testInvokeAll2() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { List> r = e.invokeAll(new ArrayList>()); assertTrue(r.isEmpty()); @@ -1258,7 +1254,7 @@ public class ThreadPoolExecutorSubclassT * invokeAll(c) throws NPE if c has null elements */ public void testInvokeAll3() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); @@ -1275,7 +1271,7 @@ public class ThreadPoolExecutorSubclassT * get of element of invokeAll(c) throws exception on failed task */ public void testInvokeAll4() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new NPETask()); @@ -1285,6 +1281,7 @@ public class ThreadPoolExecutorSubclassT future.get(); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } finally { joinPool(e); } @@ -1294,7 +1291,7 @@ public class ThreadPoolExecutorSubclassT * invokeAll(c) returns results of all completed tasks */ public void testInvokeAll5() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); @@ -1314,9 +1311,9 @@ public class ThreadPoolExecutorSubclassT * timed invokeAny(null) throws NPE */ public void testTimedInvokeAny1() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { - e.invokeAny(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (NullPointerException success) { } finally { @@ -1328,7 +1325,7 @@ public class ThreadPoolExecutorSubclassT * timed invokeAny(,,null) throws NPE */ public void testTimedInvokeAnyNullTimeUnit() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); @@ -1344,9 +1341,9 @@ public class ThreadPoolExecutorSubclassT * timed invokeAny(empty collection) throws IAE */ public void testTimedInvokeAny2() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { - e.invokeAny(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + e.invokeAny(new ArrayList>(), MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (IllegalArgumentException success) { } finally { @@ -1358,15 +1355,23 @@ public class ThreadPoolExecutorSubclassT * timed invokeAny(c) throws NPE if c has null elements */ public void testTimedInvokeAny3() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + final CountDownLatch latch = new CountDownLatch(1); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); - l.add(new StringTask()); + l.add(new Callable() { + public String call() { + try { + latch.await(); + } catch (InterruptedException ok) {} + return TEST_STRING; + }}); l.add(null); - e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (NullPointerException success) { } finally { + latch.countDown(); joinPool(e); } } @@ -1375,13 +1380,14 @@ public class ThreadPoolExecutorSubclassT * timed invokeAny(c) throws ExecutionException if no task completes */ public void testTimedInvokeAny4() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new NPETask()); - e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (ExecutionException success) { + assertTrue(success.getCause() instanceof NullPointerException); } finally { joinPool(e); } @@ -1391,12 +1397,12 @@ public class ThreadPoolExecutorSubclassT * timed invokeAny(c) returns result of some task */ public void testTimedInvokeAny5() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); l.add(new StringTask()); - String result = e.invokeAny(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); assertSame(TEST_STRING, result); } finally { joinPool(e); @@ -1407,9 +1413,9 @@ public class ThreadPoolExecutorSubclassT * timed invokeAll(null) throws NPE */ public void testTimedInvokeAll1() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { - e.invokeAll(null, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (NullPointerException success) { } finally { @@ -1421,7 +1427,7 @@ public class ThreadPoolExecutorSubclassT * timed invokeAll(,,null) throws NPE */ public void testTimedInvokeAllNullTimeUnit() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); @@ -1437,9 +1443,9 @@ public class ThreadPoolExecutorSubclassT * timed invokeAll(empty collection) returns empty collection */ public void testTimedInvokeAll2() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { - List> r = e.invokeAll(new ArrayList>(), MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + List> r = e.invokeAll(new ArrayList>(), MEDIUM_DELAY_MS, MILLISECONDS); assertTrue(r.isEmpty()); } finally { joinPool(e); @@ -1450,12 +1456,12 @@ public class ThreadPoolExecutorSubclassT * timed invokeAll(c) throws NPE if c has null elements */ public void testTimedInvokeAll3() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); l.add(null); - e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); shouldThrow(); } catch (NullPointerException success) { } finally { @@ -1467,11 +1473,11 @@ public class ThreadPoolExecutorSubclassT * get of element of invokeAll(c) throws exception on failed task */ public void testTimedInvokeAll4() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new NPETask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + List> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); assertEquals(1, result.size()); for (Future future : result) future.get(); @@ -1487,16 +1493,15 @@ public class ThreadPoolExecutorSubclassT * timed invokeAll(c) returns results of all completed tasks */ public void testTimedInvokeAll5() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); l.add(new StringTask()); - List> result = e.invokeAll(l, MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); + List> result = e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); assertEquals(2, result.size()); for (Future future : result) assertSame(TEST_STRING, future.get()); - } catch (ExecutionException success) { } finally { joinPool(e); } @@ -1506,13 +1511,13 @@ public class ThreadPoolExecutorSubclassT * timed invokeAll(c) cancels tasks not completed by timeout */ public void testTimedInvokeAll6() throws Exception { - ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ExecutorService e = new CustomTPE(2, 2, LONG_DELAY_MS, MILLISECONDS, new ArrayBlockingQueue(10)); try { ArrayList> l = new ArrayList>(); l.add(new StringTask()); l.add(Executors.callable(new MediumPossiblyInterruptedRunnable(), TEST_STRING)); l.add(new StringTask()); - List> result = e.invokeAll(l, SHORT_DELAY_MS, TimeUnit.MILLISECONDS); + List> result = e.invokeAll(l, SHORT_DELAY_MS, MILLISECONDS); assertEquals(3, result.size()); Iterator> it = result.iterator(); Future f1 = it.next(); @@ -1533,7 +1538,7 @@ public class ThreadPoolExecutorSubclassT * thread factory fails to create more */ public void testFailingThreadFactory() throws InterruptedException { - ExecutorService e = new CustomTPE(100, 100, LONG_DELAY_MS, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new FailingThreadFactory()); + ExecutorService e = new CustomTPE(100, 100, LONG_DELAY_MS, MILLISECONDS, new LinkedBlockingQueue(), new FailingThreadFactory()); try { for (int k = 0; k < 100; ++k) { e.execute(new NoOpRunnable()); @@ -1548,7 +1553,7 @@ public class ThreadPoolExecutorSubclassT * allowsCoreThreadTimeOut is by default false. */ public void testAllowsCoreThreadTimeOut() { - ThreadPoolExecutor tpe = new CustomTPE(2, 2, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor tpe = new CustomTPE(2, 2, 1000, MILLISECONDS, new ArrayBlockingQueue(10)); assertFalse(tpe.allowsCoreThreadTimeOut()); joinPool(tpe); } @@ -1557,7 +1562,7 @@ public class ThreadPoolExecutorSubclassT * allowCoreThreadTimeOut(true) causes idle threads to time out */ public void testAllowCoreThreadTimeOut_true() throws InterruptedException { - ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, MILLISECONDS, new ArrayBlockingQueue(10)); tpe.allowCoreThreadTimeOut(true); tpe.execute(new NoOpRunnable()); try { @@ -1572,7 +1577,7 @@ public class ThreadPoolExecutorSubclassT * allowCoreThreadTimeOut(false) causes idle threads not to time out */ public void testAllowCoreThreadTimeOut_false() throws InterruptedException { - ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, TimeUnit.MILLISECONDS, new ArrayBlockingQueue(10)); + ThreadPoolExecutor tpe = new CustomTPE(2, 10, 10, MILLISECONDS, new ArrayBlockingQueue(10)); tpe.allowCoreThreadTimeOut(false); tpe.execute(new NoOpRunnable()); try {