--- jsr166/src/test/tck/ScheduledExecutorTest.java 2017/05/29 19:15:03 1.93 +++ jsr166/src/test/tck/ScheduledExecutorTest.java 2017/05/29 22:44:27 1.94 @@ -11,6 +11,8 @@ import static java.util.concurrent.TimeU import static java.util.concurrent.TimeUnit.SECONDS; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.concurrent.BlockingQueue; @@ -257,7 +259,7 @@ public class ScheduledExecutorTest exten try { p.shutdown(); p.schedule(new NoOpRunnable(), - MEDIUM_DELAY_MS, MILLISECONDS); + randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (RejectedExecutionException success) { } catch (SecurityException ok) {} @@ -273,7 +275,7 @@ public class ScheduledExecutorTest exten try { p.shutdown(); p.schedule(new NoOpCallable(), - MEDIUM_DELAY_MS, MILLISECONDS); + randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (RejectedExecutionException success) { } catch (SecurityException ok) {} @@ -289,7 +291,7 @@ public class ScheduledExecutorTest exten try { p.shutdown(); p.schedule(new NoOpCallable(), - MEDIUM_DELAY_MS, MILLISECONDS); + randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (RejectedExecutionException success) { } catch (SecurityException ok) {} @@ -964,7 +966,7 @@ public class ScheduledExecutorTest exten } /** - * invokeAny(null) throws NPE + * invokeAny(null) throws NullPointerException */ public void testInvokeAny1() throws Exception { final ExecutorService e = new ScheduledThreadPoolExecutor(2); @@ -977,7 +979,7 @@ public class ScheduledExecutorTest exten } /** - * invokeAny(empty collection) throws IAE + * invokeAny(empty collection) throws IllegalArgumentException */ public void testInvokeAny2() throws Exception { final ExecutorService e = new ScheduledThreadPoolExecutor(2); @@ -990,7 +992,7 @@ public class ScheduledExecutorTest exten } /** - * invokeAny(c) throws NPE if c has null elements + * invokeAny(c) throws NullPointerException if c has null elements */ public void testInvokeAny3() throws Exception { CountDownLatch latch = new CountDownLatch(1); @@ -1052,12 +1054,14 @@ public class ScheduledExecutorTest exten } /** - * invokeAll(empty collection) returns empty collection + * invokeAll(empty collection) returns empty list */ public void testInvokeAll2() throws Exception { final ExecutorService e = new ScheduledThreadPoolExecutor(2); + final Collection> emptyCollection + = Collections.emptyList(); try (PoolCleaner cleaner = cleaner(e)) { - List> r = e.invokeAll(new ArrayList>()); + List> r = e.invokeAll(emptyCollection); assertTrue(r.isEmpty()); } } @@ -1120,14 +1124,14 @@ public class ScheduledExecutorTest exten final ExecutorService e = new ScheduledThreadPoolExecutor(2); try (PoolCleaner cleaner = cleaner(e)) { try { - e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS); + e.invokeAny(null, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (NullPointerException success) {} } } /** - * timed invokeAny(,,null) throws NPE + * timed invokeAny(,,null) throws NullPointerException */ public void testTimedInvokeAnyNullTimeUnit() throws Exception { final ExecutorService e = new ScheduledThreadPoolExecutor(2); @@ -1135,20 +1139,22 @@ public class ScheduledExecutorTest exten List> l = new ArrayList<>(); l.add(new StringTask()); try { - e.invokeAny(l, MEDIUM_DELAY_MS, null); + e.invokeAny(l, randomTimeout(), null); shouldThrow(); } catch (NullPointerException success) {} } } /** - * timed invokeAny(empty collection) throws IAE + * timed invokeAny(empty collection) throws IllegalArgumentException */ public void testTimedInvokeAny2() throws Exception { final ExecutorService e = new ScheduledThreadPoolExecutor(2); + final Collection> emptyCollection + = Collections.emptyList(); try (PoolCleaner cleaner = cleaner(e)) { try { - e.invokeAny(new ArrayList>(), MEDIUM_DELAY_MS, MILLISECONDS); + e.invokeAny(emptyCollection, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (IllegalArgumentException success) {} } @@ -1165,7 +1171,7 @@ public class ScheduledExecutorTest exten l.add(latchAwaitingStringTask(latch)); l.add(null); try { - e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); + e.invokeAny(l, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (NullPointerException success) {} latch.countDown(); @@ -1214,7 +1220,7 @@ public class ScheduledExecutorTest exten final ExecutorService e = new ScheduledThreadPoolExecutor(2); try (PoolCleaner cleaner = cleaner(e)) { try { - e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS); + e.invokeAll(null, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (NullPointerException success) {} } @@ -1229,20 +1235,22 @@ public class ScheduledExecutorTest exten List> l = new ArrayList<>(); l.add(new StringTask()); try { - e.invokeAll(l, MEDIUM_DELAY_MS, null); + e.invokeAll(l, randomTimeout(), null); shouldThrow(); } catch (NullPointerException success) {} } } /** - * timed invokeAll(empty collection) returns empty collection + * timed invokeAll(empty collection) returns empty list */ public void testTimedInvokeAll2() throws Exception { final ExecutorService e = new ScheduledThreadPoolExecutor(2); + final Collection> emptyCollection + = Collections.emptyList(); try (PoolCleaner cleaner = cleaner(e)) { - List> r = e.invokeAll(new ArrayList>(), - MEDIUM_DELAY_MS, MILLISECONDS); + List> r = + e.invokeAll(emptyCollection, randomTimeout(), randomTimeUnit()); assertTrue(r.isEmpty()); } } @@ -1257,7 +1265,7 @@ public class ScheduledExecutorTest exten l.add(new StringTask()); l.add(null); try { - e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS); + e.invokeAll(l, randomTimeout(), randomTimeUnit()); shouldThrow(); } catch (NullPointerException success) {} }