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

Comparing jsr166/src/test/tck/AbstractExecutorServiceTest.java (file contents):
Revision 1.45 by jsr166, Wed Jan 4 06:09:58 2017 UTC vs.
Revision 1.46 by jsr166, Mon May 29 22:44:26 2017 UTC

# Line 11 | Line 11 | import static java.util.concurrent.TimeU
11   import java.security.PrivilegedAction;
12   import java.security.PrivilegedExceptionAction;
13   import java.util.ArrayList;
14 + import java.util.Collection;
15   import java.util.Collections;
16   import java.util.List;
17   import java.util.concurrent.AbstractExecutorService;
# Line 249 | Line 250 | public class AbstractExecutorServiceTest
250      }
251  
252      /**
253 <     * invokeAny(empty collection) throws IAE
253 >     * invokeAny(empty collection) throws IllegalArgumentException
254       */
255      public void testInvokeAny2() throws Exception {
256          final ExecutorService e = new DirectExecutorService();
257 +        final Collection<Callable<String>> emptyCollection
258 +            = Collections.emptyList();
259          try (PoolCleaner cleaner = cleaner(e)) {
260              try {
261 <                e.invokeAny(new ArrayList<Callable<String>>());
261 >                e.invokeAny(emptyCollection);
262                  shouldThrow();
263              } catch (IllegalArgumentException success) {}
264          }
# Line 323 | Line 326 | public class AbstractExecutorServiceTest
326      }
327  
328      /**
329 <     * invokeAll(empty collection) returns empty collection
329 >     * invokeAll(empty collection) returns empty list
330       */
331      public void testInvokeAll2() throws InterruptedException {
332          final ExecutorService e = new DirectExecutorService();
333 +        final Collection<Callable<String>> emptyCollection
334 +            = Collections.emptyList();
335          try (PoolCleaner cleaner = cleaner(e)) {
336 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>());
336 >            List<Future<String>> r = e.invokeAll(emptyCollection);
337              assertTrue(r.isEmpty());
338          }
339      }
# Line 391 | Line 396 | public class AbstractExecutorServiceTest
396          final ExecutorService e = new DirectExecutorService();
397          try (PoolCleaner cleaner = cleaner(e)) {
398              try {
399 <                e.invokeAny(null, MEDIUM_DELAY_MS, MILLISECONDS);
399 >                e.invokeAny(null, randomTimeout(), randomTimeUnit());
400                  shouldThrow();
401              } catch (NullPointerException success) {}
402          }
403      }
404  
405      /**
406 <     * timed invokeAny(null time unit) throws NPE
406 >     * timed invokeAny(null time unit) throws NullPointerException
407       */
408      public void testTimedInvokeAnyNullTimeUnit() throws Exception {
409          final ExecutorService e = new DirectExecutorService();
# Line 406 | Line 411 | public class AbstractExecutorServiceTest
411              List<Callable<String>> l = new ArrayList<>();
412              l.add(new StringTask());
413              try {
414 <                e.invokeAny(l, MEDIUM_DELAY_MS, null);
414 >                e.invokeAny(l, randomTimeout(), null);
415                  shouldThrow();
416              } catch (NullPointerException success) {}
417          }
418      }
419  
420      /**
421 <     * timed invokeAny(empty collection) throws IAE
421 >     * timed invokeAny(empty collection) throws IllegalArgumentException
422       */
423      public void testTimedInvokeAny2() throws Exception {
424          final ExecutorService e = new DirectExecutorService();
425 +        final Collection<Callable<String>> emptyCollection
426 +            = Collections.emptyList();
427          try (PoolCleaner cleaner = cleaner(e)) {
428              try {
429 <                e.invokeAny(new ArrayList<Callable<String>>(),
423 <                            MEDIUM_DELAY_MS, MILLISECONDS);
429 >                e.invokeAny(emptyCollection, randomTimeout(), randomTimeUnit());
430                  shouldThrow();
431              } catch (IllegalArgumentException success) {}
432          }
# Line 437 | Line 443 | public class AbstractExecutorServiceTest
443                        public Long call() { throw new ArithmeticException(); }});
444              l.add(null);
445              try {
446 <                e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS);
446 >                e.invokeAny(l, randomTimeout(), randomTimeUnit());
447                  shouldThrow();
448              } catch (NullPointerException success) {}
449          }
# Line 479 | Line 485 | public class AbstractExecutorServiceTest
485      }
486  
487      /**
488 <     * timed invokeAll(null) throws NPE
488 >     * timed invokeAll(null) throws NullPointerException
489       */
490      public void testTimedInvokeAll1() throws InterruptedException {
491          final ExecutorService e = new DirectExecutorService();
492          try (PoolCleaner cleaner = cleaner(e)) {
493              try {
494 <                e.invokeAll(null, MEDIUM_DELAY_MS, MILLISECONDS);
494 >                e.invokeAll(null, randomTimeout(), randomTimeUnit());
495                  shouldThrow();
496              } catch (NullPointerException success) {}
497          }
# Line 500 | Line 506 | public class AbstractExecutorServiceTest
506              List<Callable<String>> l = new ArrayList<>();
507              l.add(new StringTask());
508              try {
509 <                e.invokeAll(l, MEDIUM_DELAY_MS, null);
509 >                e.invokeAll(l, randomTimeout(), null);
510                  shouldThrow();
511              } catch (NullPointerException success) {}
512          }
513      }
514  
515      /**
516 <     * timed invokeAll(empty collection) returns empty collection
516 >     * timed invokeAll(empty collection) returns empty list
517       */
518      public void testTimedInvokeAll2() throws InterruptedException {
519          final ExecutorService e = new DirectExecutorService();
520 +        final Collection<Callable<String>> emptyCollection
521 +            = Collections.emptyList();
522          try (PoolCleaner cleaner = cleaner(e)) {
523 <            List<Future<String>> r = e.invokeAll(new ArrayList<Callable<String>>(), MEDIUM_DELAY_MS, MILLISECONDS);
523 >            List<Future<String>> r =
524 >                e.invokeAll(emptyCollection, randomTimeout(), randomTimeUnit());
525              assertTrue(r.isEmpty());
526          }
527      }
528  
529      /**
530 <     * timed invokeAll(c) throws NPE if c has null elements
530 >     * timed invokeAll(c) throws NullPointerException if c has null elements
531       */
532      public void testTimedInvokeAll3() throws InterruptedException {
533          final ExecutorService e = new DirectExecutorService();
# Line 527 | Line 536 | public class AbstractExecutorServiceTest
536              l.add(new StringTask());
537              l.add(null);
538              try {
539 <                e.invokeAll(l, MEDIUM_DELAY_MS, MILLISECONDS);
539 >                e.invokeAll(l, randomTimeout(), randomTimeUnit());
540                  shouldThrow();
541              } catch (NullPointerException success) {}
542          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines