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

Comparing jsr166/src/test/tck/RecursiveTaskTest.java (file contents):
Revision 1.20 by jsr166, Sun Nov 21 08:25:10 2010 UTC vs.
Revision 1.24 by jsr166, Mon Nov 22 07:45:50 2010 UTC

# Line 90 | Line 90 | public class RecursiveTaskTest extends J
90          assertNull(a.getException());
91          assertSame(expected, a.getRawResult());
92          assertSame(expected, a.join());
93 +        assertFalse(a.cancel(false));
94 +        assertFalse(a.cancel(true));
95          try {
96              assertSame(expected, a.get());
97          } catch (Throwable fail) { threadUnexpectedException(fail); }
# Line 145 | Line 147 | public class RecursiveTaskTest extends J
147          } catch (Throwable fail) { threadUnexpectedException(fail); }
148      }
149  
150 <    void checkTaskThrew(RecursiveTask a, Throwable t) {
150 >    void checkCompletedAbnormally(RecursiveTask a, Throwable t) {
151          assertTrue(a.isDone());
152          assertFalse(a.isCancelled());
153          assertFalse(a.isCompletedNormally());
154          assertTrue(a.isCompletedAbnormally());
155          assertSame(t, a.getException());
156          assertNull(a.getRawResult());
157 +        assertFalse(a.cancel(false));
158 +        assertFalse(a.cancel(true));
159  
160          try {
161              a.join();
# Line 344 | Line 348 | public class RecursiveTaskTest extends J
348                      f.invoke();
349                      shouldThrow();
350                  } catch (FJException success) {
351 <                    checkTaskThrew(f, success);
351 >                    checkCompletedAbnormally(f, success);
352                  }
353                  return NoResult;
354              }};
# Line 360 | Line 364 | public class RecursiveTaskTest extends J
364                  FailingFibTask f = new FailingFibTask(8);
365                  f.quietlyInvoke();
366                  assertTrue(f.getException() instanceof FJException);
367 <                checkTaskThrew(f, f.getException());
367 >                checkCompletedAbnormally(f, f.getException());
368                  return NoResult;
369              }};
370          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 378 | Line 382 | public class RecursiveTaskTest extends J
382                      Integer r = f.join();
383                      shouldThrow();
384                  } catch (FJException success) {
385 <                    checkTaskThrew(f, success);
385 >                    checkCompletedAbnormally(f, success);
386                  }
387                  return NoResult;
388              }};
# Line 397 | Line 401 | public class RecursiveTaskTest extends J
401                      Integer r = f.get();
402                      shouldThrow();
403                  } catch (ExecutionException success) {
404 <                    checkTaskThrew(f, success.getCause());
404 >                    Throwable cause = success.getCause();
405 >                    assertTrue(cause instanceof FJException);
406 >                    checkCompletedAbnormally(f, cause);
407                  }
408                  return NoResult;
409              }};
# Line 416 | Line 422 | public class RecursiveTaskTest extends J
422                      Integer r = f.get(5L, SECONDS);
423                      shouldThrow();
424                  } catch (ExecutionException success) {
425 <                    checkTaskThrew(f, success.getCause());
425 >                    Throwable cause = success.getCause();
426 >                    assertTrue(cause instanceof FJException);
427 >                    checkCompletedAbnormally(f, cause);
428                  }
429                  return NoResult;
430              }};
# Line 433 | Line 441 | public class RecursiveTaskTest extends J
441                  assertSame(f, f.fork());
442                  f.quietlyJoin();
443                  assertTrue(f.getException() instanceof FJException);
444 <                checkTaskThrew(f, f.getException());
444 >                checkCompletedAbnormally(f, f.getException());
445                  return NoResult;
446              }};
447          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 577 | Line 585 | public class RecursiveTaskTest extends J
585      public void testInForkJoinPool2() {
586          RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() {
587              public Integer realCompute() {
588 <                assertTrue(!inForkJoinPool());
588 >                assertFalse(inForkJoinPool());
589                  return NoResult;
590              }};
591          assertSame(NoResult, a.invoke());
# Line 594 | Line 602 | public class RecursiveTaskTest extends J
602                  return NoResult;
603              }
604          };
605 <        a.invoke();
605 >        assertSame(NoResult, a.invoke());
606      }
607  
608      /**
# Line 633 | Line 641 | public class RecursiveTaskTest extends J
641                          f.invoke();
642                          shouldThrow();
643                      } catch (FJException success) {
644 <                        checkTaskThrew(f, success);
644 >                        checkCompletedAbnormally(f, success);
645                      }
646                      f.reinitialize();
647                      checkNotDone(f);
# Line 655 | Line 663 | public class RecursiveTaskTest extends J
663                      Integer r = f.invoke();
664                      shouldThrow();
665                  } catch (FJException success) {
666 <                    checkTaskThrew(f, success);
666 >                    checkCompletedAbnormally(f, success);
667                  }
668                  return NoResult;
669              }};
# Line 687 | Line 695 | public class RecursiveTaskTest extends J
695                  FibTask f = new FibTask(8);
696                  FibTask g = new FibTask(9);
697                  invokeAll(f, g);
698 <                checkCompletesNormally(f, 21);
699 <                checkCompletesNormally(g, 34);
698 >                checkCompletedNormally(f, 21);
699 >                checkCompletedNormally(g, 34);
700                  return NoResult;
701              }};
702          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 702 | Line 710 | public class RecursiveTaskTest extends J
710              public Integer realCompute() {
711                  FibTask f = new FibTask(8);
712                  invokeAll(f);
713 <                checkCompletesNormally(f, 21);
713 >                checkCompletedNormally(f, 21);
714                  return NoResult;
715              }};
716          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 718 | Line 726 | public class RecursiveTaskTest extends J
726                  FibTask g = new FibTask(9);
727                  FibTask h = new FibTask(7);
728                  invokeAll(f, g, h);
729 <                checkCompletesNormally(f, 21);
730 <                checkCompletesNormally(g, 34);
731 <                checkCompletesNormally(h, 13);
729 >                assertTrue(f.isDone());
730 >                assertTrue(g.isDone());
731 >                assertTrue(h.isDone());
732 >                checkCompletedNormally(f, 21);
733 >                checkCompletedNormally(g, 34);
734 >                checkCompletedNormally(h, 13);
735                  return NoResult;
736              }};
737          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 740 | Line 751 | public class RecursiveTaskTest extends J
751                  set.add(g);
752                  set.add(h);
753                  invokeAll(set);
754 <                checkCompletesNormally(f, 21);
755 <                checkCompletesNormally(g, 34);
756 <                checkCompletesNormally(h, 13);
754 >                assertTrue(f.isDone());
755 >                assertTrue(g.isDone());
756 >                assertTrue(h.isDone());
757 >                checkCompletedNormally(f, 21);
758 >                checkCompletedNormally(g, 34);
759 >                checkCompletedNormally(h, 13);
760                  return NoResult;
761              }};
762          assertSame(NoResult, testInvokeOnPool(mainPool(), a));
# Line 779 | Line 793 | public class RecursiveTaskTest extends J
793                      invokeAll(f, g);
794                      shouldThrow();
795                  } catch (FJException success) {
796 <                    checkTaskThrew(g, success);
796 >                    checkCompletedAbnormally(g, success);
797                  }
798                  return NoResult;
799              }};
# Line 797 | Line 811 | public class RecursiveTaskTest extends J
811                      invokeAll(g);
812                      shouldThrow();
813                  } catch (FJException success) {
814 <                    checkTaskThrew(g, success);
814 >                    checkCompletedAbnormally(g, success);
815                  }
816                  return NoResult;
817              }};
# Line 817 | Line 831 | public class RecursiveTaskTest extends J
831                      invokeAll(f, g, h);
832                      shouldThrow();
833                  } catch (FJException success) {
834 <                    checkTaskThrew(g, success);
834 >                    checkCompletedAbnormally(g, success);
835                  }
836                  return NoResult;
837              }};
# Line 841 | Line 855 | public class RecursiveTaskTest extends J
855                      invokeAll(set);
856                      shouldThrow();
857                  } catch (FJException success) {
858 <                    checkTaskThrew(f, success);
858 >                    checkCompletedAbnormally(f, success);
859                  }
860                  return NoResult;
861              }};
# Line 883 | Line 897 | public class RecursiveTaskTest extends J
897                  assertSame(f, f.fork());
898                  assertTrue(getSurplusQueuedTaskCount() > 0);
899                  helpQuiesce();
900 +                assertEquals(0, getSurplusQueuedTaskCount());
901                  checkCompletedNormally(f, 21);
902                  checkCompletedNormally(g, 34);
903                  checkCompletedNormally(h, 13);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines