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

Comparing jsr166/src/test/tck/ForkJoinPoolTest.java (file contents):
Revision 1.6 by jsr166, Mon Aug 3 22:08:07 2009 UTC vs.
Revision 1.10 by jsr166, Sat Nov 21 10:25:05 2009 UTC

# Line 170 | Line 170 | public class ForkJoinPoolTest extends JS
170          try {
171              new ForkJoinPool(-1);
172              shouldThrow();
173 <        }
174 <        catch (IllegalArgumentException success) {}
173 >        } catch (IllegalArgumentException success) {}
174      }
175  
176      /**
# Line 181 | Line 180 | public class ForkJoinPoolTest extends JS
180          try {
181              new ForkJoinPool(1, null);
182              shouldThrow();
183 <        } catch (NullPointerException success) {
185 <        }
183 >        } catch (NullPointerException success) {}
184      }
185  
186  
# Line 416 | Line 414 | public class ForkJoinPoolTest extends JS
414              int r = f.get();
415              assertTrue(r ==  832040);
416          } finally {
417 <            joinPool(p);
417 >            p.shutdownNow(); // don't wait out shutdown
418          }
419      }
420  
# Line 606 | Line 604 | public class ForkJoinPoolTest extends JS
604              TrackedShortRunnable task = null;
605              Future<?> future = e.submit(task);
606              shouldThrow();
607 <        } catch (NullPointerException success) {
610 <        }
607 >        } catch (NullPointerException success) {}
608      }
609  
610  
# Line 620 | Line 617 | public class ForkJoinPoolTest extends JS
617              StringTask t = null;
618              Future<String> future = e.submit(t);
619              shouldThrow();
620 <        } catch (NullPointerException success) {
624 <        }
620 >        } catch (NullPointerException success) {}
621      }
622  
623  
# Line 636 | Line 632 | public class ForkJoinPoolTest extends JS
632              void realRun() throws Throwable {
633                  p.submit(new CheckedCallable<Object>() {
634                      public Object realCall() throws Throwable {
635 <                        Thread.sleep(MEDIUM_DELAY_MS);
635 >                        try {
636 >                            Thread.sleep(MEDIUM_DELAY_MS);
637 >                        } catch (InterruptedException ok) {
638 >                        }
639                          return null;
640                      }}).get();
641              }});
# Line 644 | Line 643 | public class ForkJoinPoolTest extends JS
643          t.start();
644          Thread.sleep(SHORT_DELAY_MS);
645          t.interrupt();
646 +        t.join();
647 +        p.shutdownNow();
648          joinPool(p);
649      }
650  
# Line 653 | Line 654 | public class ForkJoinPoolTest extends JS
654       */
655      public void testSubmitEE() throws Throwable {
656          ForkJoinPool p = new ForkJoinPool(1);
656
657          try {
658 <            Callable c = new Callable() {
659 <                    public Object call() {
660 <                        int i = 5/0;
661 <                        return Boolean.TRUE;
662 <                    }
663 <                };
664 <
665 <            for (int i = 0; i < 5; i++) {
666 <                p.submit(c).get();
667 <            }
658 >            p.submit(new Callable() {
659 >                public Object call() {
660 >                    int i = 5/0;
661 >                    return Boolean.TRUE;
662 >                }}).get();
663              shouldThrow();
664 <        } catch (ExecutionException success) {
665 <        }
664 >        } catch (ExecutionException success) {}
665 >
666          joinPool(p);
667      }
668  
# Line 700 | Line 695 | public class ForkJoinPoolTest extends JS
695      }
696  
697      /**
698 <     * invokeAny(c) throws NullPointerException if c has null elements
698 >     * invokeAny(c) throws NullPointerException if c has a single null element
699       */
700      public void testInvokeAny3() throws Throwable {
701          ExecutorService e = new ForkJoinPool(1);
702          try {
703              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
709            l.add(new StringTask());
704              l.add(null);
705              e.invokeAny(l);
706              shouldThrow();
# Line 717 | Line 711 | public class ForkJoinPoolTest extends JS
711      }
712  
713      /**
714 <     * invokeAny(c) throws ExecutionException if no task in c completes
714 >     * invokeAny(c) throws NullPointerException if c has null elements
715       */
716      public void testInvokeAny4() throws Throwable {
717          ExecutorService e = new ForkJoinPool(1);
718          try {
719              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
720 +            l.add(new Callable<String>() {
721 +                public String call() {
722 +                    // The delay gives the pool a chance to notice
723 +                    // the null element.
724 +                    sleepTillInterrupted(SMALL_DELAY_MS);
725 +                    return "foo";
726 +                }});
727 +            l.add(null);
728 +            e.invokeAny(l);
729 +            shouldThrow();
730 +        } catch (NullPointerException success) {
731 +        } finally {
732 +            joinPool(e);
733 +        }
734 +    }
735 +
736 +    /**
737 +     * invokeAny(c) throws ExecutionException if no task in c completes
738 +     */
739 +    public void testInvokeAny5() throws Throwable {
740 +        ExecutorService e = new ForkJoinPool(1);
741 +        try {
742 +            ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();
743              l.add(new NPETask());
744              e.invokeAny(l);
745              shouldThrow();
# Line 735 | Line 752 | public class ForkJoinPoolTest extends JS
752      /**
753       * invokeAny(c) returns result of some task in c if at least one completes
754       */
755 <    public void testInvokeAny5() throws Throwable {
755 >    public void testInvokeAny6() throws Throwable {
756          ExecutorService e = new ForkJoinPool(1);
757          try {
758              ArrayList<Callable<String>> l = new ArrayList<Callable<String>>();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines