[cvs] / jsr166 / src / test / tck / AbstractExecutorServiceTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/AbstractExecutorServiceTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.46

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8