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

Comparing jsr166/src/test/tck/ScheduledExecutorSubclassTest.java (file contents):
Revision 1.67 by jsr166, Mon May 29 19:15:02 2017 UTC vs.
Revision 1.68 by jsr166, Mon May 29 22:44:27 2017 UTC

# Line 9 | Line 9 | import static java.util.concurrent.TimeU
9   import static java.util.concurrent.TimeUnit.SECONDS;
10  
11   import java.util.ArrayList;
12 + import java.util.Collection;
13 + import java.util.Collections;
14   import java.util.HashSet;
15   import java.util.List;
16   import java.util.concurrent.BlockingQueue;
# Line 313 | Line 315 | public class ScheduledExecutorSubclassTe
315              try {
316                  p.shutdown();
317                  p.schedule(new NoOpRunnable(),
318 <                           MEDIUM_DELAY_MS, MILLISECONDS);
318 >                           randomTimeout(), randomTimeUnit());
319                  shouldThrow();
320              } catch (RejectedExecutionException success) {
321              } catch (SecurityException ok) {}
# Line 329 | Line 331 | public class ScheduledExecutorSubclassTe
331              try {
332                  p.shutdown();
333                  p.schedule(new NoOpCallable(),
334 <                           MEDIUM_DELAY_MS, MILLISECONDS);
334 >                           randomTimeout(), randomTimeUnit());
335                  shouldThrow();
336              } catch (RejectedExecutionException success) {
337              } catch (SecurityException ok) {}
# Line 345 | Line 347 | public class ScheduledExecutorSubclassTe
347              try {
348                  p.shutdown();
349                  p.schedule(new NoOpCallable(),
350 <                           MEDIUM_DELAY_MS, MILLISECONDS);
350 >                           randomTimeout(), randomTimeUnit());
351                  shouldThrow();
352              } catch (RejectedExecutionException success) {
353              } catch (SecurityException ok) {}
# Line 1018 | Line 1020 | public class ScheduledExecutorSubclassTe
1020      }
1021  
1022      /**
1023 <     * invokeAny(empty collection) throws IAE
1023 >     * invokeAny(empty collection) throws IllegalArgumentException
1024       */
1025      public void testInvokeAny2() throws Exception {
1026          final ExecutorService e = new CustomExecutor(2);
# Line 1093 | Line 1095 | public class ScheduledExecutorSubclassTe
1095      }
1096  
1097      /**
1098 <     * invokeAll(empty collection) returns empty collection
1098 >     * invokeAll(empty collection) returns empty list
1099       */
1100      public void testInvokeAll2() throws Exception {
1101          final ExecutorService e = new CustomExecutor(2);
1102 +        final Collection<Callable<String>> emptyCollection
1103 +            = Collections.emptyList();
1104          try (PoolCleaner cleaner = cleaner(e)) {
1105 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
1105 >            List<Future<String>> r = e.invokeAll(emptyCollection);
1106              assertTrue(r.isEmpty());
1107          }
1108      }
# Line 1161 | Line 1165 | public class ScheduledExecutorSubclassTe
1165          final ExecutorService e = new CustomExecutor(2);
1166          try (PoolCleaner cleaner = cleaner(e)) {
1167              try {
1168 <                e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
1168 >                e.invokeAny(null, randomTimeout(), randomTimeUnit());
1169                  shouldThrow();
1170              } catch (NullPointerException success) {}
1171          }
# Line 1176 | Line 1180 | public class ScheduledExecutorSubclassTe
1180              List<Callable<String>> l = new ArrayList<>();
1181              l.add(new StringTask());
1182              try {
1183 <                e.invokeAny(l, MEDIUM_DELAY_MS, null);
1183 >                e.invokeAny(l, randomTimeout(), null);
1184                  shouldThrow();
1185              } catch (NullPointerException success) {}
1186          }
1187      }
1188  
1189      /**
1190 <     * timed invokeAny(empty collection) throws IAE
1190 >     * timed invokeAny(empty collection) throws IllegalArgumentException
1191       */
1192      public void testTimedInvokeAny2() throws Exception {
1193          final ExecutorService e = new CustomExecutor(2);
1194 +        final Collection<Callable<String>> emptyCollection
1195 +            = Collections.emptyList();
1196          try (PoolCleaner cleaner = cleaner(e)) {
1197              try {
1198 <                e.invokeAny(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1198 >                e.invokeAny(emptyCollection, randomTimeout(), randomTimeUnit());
1199                  shouldThrow();
1200              } catch (IllegalArgumentException success) {}
1201          }
# Line 1206 | Line 1212 | public class ScheduledExecutorSubclassTe
1212              l.add(latchAwaitingStringTask(latch));
1213              l.add(null);
1214              try {
1215 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
1215 >                e.invokeAny(l, randomTimeout(), randomTimeUnit());
1216                  shouldThrow();
1217              } catch (NullPointerException success) {}
1218              latch.countDown();
# Line 1249 | Line 1255 | public class ScheduledExecutorSubclassTe
1255      }
1256  
1257      /**
1258 <     * timed invokeAll(null) throws NPE
1258 >     * timed invokeAll(null) throws NullPointerException
1259       */
1260      public void testTimedInvokeAll1() throws Exception {
1261          final ExecutorService e = new CustomExecutor(2);
1262          try (PoolCleaner cleaner = cleaner(e)) {
1263              try {
1264 <                e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
1264 >                e.invokeAll(null, randomTimeout(), randomTimeUnit());
1265                  shouldThrow();
1266              } catch (NullPointerException success) {}
1267          }
1268      }
1269  
1270      /**
1271 <     * timed invokeAll(,,null) throws NPE
1271 >     * timed invokeAll(,,null) throws NullPointerException
1272       */
1273      public void testTimedInvokeAllNullTimeUnit() throws Exception {
1274          final ExecutorService e = new CustomExecutor(2);
# Line 1270 | Line 1276 | public class ScheduledExecutorSubclassTe
1276              List<Callable<String>> l = new ArrayList<>();
1277              l.add(new StringTask());
1278              try {
1279 <                e.invokeAll(l, MEDIUM_DELAY_MS, null);
1279 >                e.invokeAll(l, randomTimeout(), null);
1280                  shouldThrow();
1281              } catch (NullPointerException success) {}
1282          }
1283      }
1284  
1285      /**
1286 <     * timed invokeAll(empty collection) returns empty collection
1286 >     * timed invokeAll(empty collection) returns empty list
1287       */
1288      public void testTimedInvokeAll2() throws Exception {
1289          final ExecutorService e = new CustomExecutor(2);
1290 +        final Collection<Callable<String>> emptyCollection
1291 +            = Collections.emptyList();
1292          try (PoolCleaner cleaner = cleaner(e)) {
1293 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
1293 >            List<Future<String>> r =
1294 >                e.invokeAll(emptyCollection, randomTimeout(), randomTimeUnit());
1295              assertTrue(r.isEmpty());
1296          }
1297      }
# Line 1297 | Line 1306 | public class ScheduledExecutorSubclassTe
1306              l.add(new StringTask());
1307              l.add(null);
1308              try {
1309 <                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1309 >                e.invokeAll(l, randomTimeout(), randomTimeUnit());
1310                  shouldThrow();
1311              } catch (NullPointerException success) {}
1312          }
# Line 1308 | Line 1317 | public class ScheduledExecutorSubclassTe
1317       */
1318      public void testTimedInvokeAll4() throws Exception {
1319          final ExecutorService e = new CustomExecutor(2);
1320 +        final Collection<Callable<String>> c = new ArrayList<>();
1321 +        c.add(new NPETask());
1322          try (PoolCleaner cleaner = cleaner(e)) {
1312            List<Callable<String>> l = new ArrayList<>();
1313            l.add(new NPETask());
1323              List<Future<String>> futures =
1324 <                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
1324 >                e.invokeAll(c, LONG_DELAY_MS, MILLISECONDS);
1325              assertEquals(1, futures.size());
1326              try {
1327                  futures.get(0).get();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines