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

Comparing jsr166/src/test/tck/RecursiveActionTest.java (file contents):
Revision 1.29 by dl, Tue Feb 22 01:18:59 2011 UTC vs.
Revision 1.33 by jsr166, Fri Jun 24 18:49:56 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7   import junit.framework.*;
# Line 267 | Line 267 | public class RecursiveActionTest extends
267                  assertEquals(21, f.result);
268                  checkCompletedNormally(f);
269  
270 <                f.reinitialize();
270 >                f = new FibAction(8);
271                  f.cancel(true);
272                  assertSame(f, f.fork());
273                  myself.interrupt();
# Line 280 | Line 280 | public class RecursiveActionTest extends
280                      checkCancelled(f);
281                  }
282  
283 <                f.reinitialize();
283 >                f = new FibAction(8);
284                  f.completeExceptionally(new FJException());
285                  assertSame(f, f.fork());
286                  myself.interrupt();
# Line 294 | Line 294 | public class RecursiveActionTest extends
294                  }
295  
296                  // test quietlyJoin()
297 <                f.reinitialize();
297 >                f = new FibAction(8);
298                  assertSame(f, f.fork());
299                  myself.interrupt();
300                  assertTrue(myself.isInterrupted());
# Line 303 | Line 303 | public class RecursiveActionTest extends
303                  assertEquals(21, f.result);
304                  checkCompletedNormally(f);
305  
306 <                f.reinitialize();
306 >                f = new FibAction(8);
307                  f.cancel(true);
308                  assertSame(f, f.fork());
309                  myself.interrupt();
# Line 312 | Line 312 | public class RecursiveActionTest extends
312                  Thread.interrupted();
313                  checkCancelled(f);
314  
315 <                f.reinitialize();
315 >                f = new FibAction(8);
316                  f.completeExceptionally(new FJException());
317                  assertSame(f, f.fork());
318                  myself.interrupt();
# Line 490 | Line 490 | public class RecursiveActionTest extends
490          testInvokeOnPool(mainPool(), a);
491      }
492  
493
493      /**
494       * helpQuiesce returns when tasks are complete.
495       * getQueuedTaskCount returns 0 when quiescent
# Line 500 | Line 499 | public class RecursiveActionTest extends
499              public void realCompute() {
500                  FibAction f = new FibAction(8);
501                  assertSame(f, f.fork());
502 <                f.helpQuiesce();
502 >                helpQuiesce();
503                  assertEquals(21, f.result);
504                  assertEquals(0, getQueuedTaskCount());
505                  checkCompletedNormally(f);
# Line 508 | Line 507 | public class RecursiveActionTest extends
507          testInvokeOnPool(mainPool(), a);
508      }
509  
511
510      /**
511       * invoke task throws exception when task completes abnormally
512       */
# Line 778 | Line 776 | public class RecursiveActionTest extends
776          testInvokeOnPool(mainPool, a);
777      }
778  
781
779      /**
780       * setRawResult(null) succeeds
781       */
# Line 792 | Line 789 | public class RecursiveActionTest extends
789      }
790  
791      /**
792 <     * A reinitialized task may be re-invoked
792 >     * A reinitialized normally completed task may be re-invoked
793       */
794      public void testReinitialize() {
795          RecursiveAction a = new CheckedRecursiveAction() {
# Line 812 | Line 809 | public class RecursiveActionTest extends
809      }
810  
811      /**
812 +     * A reinitialized abnormally completed task may be re-invoked
813 +     */
814 +    public void testReinitializeAbnormal() {
815 +        RecursiveAction a = new CheckedRecursiveAction() {
816 +            public void realCompute() {
817 +                FailingFibAction f = new FailingFibAction(8);
818 +                checkNotDone(f);
819 +
820 +                for (int i = 0; i < 3; i++) {
821 +                    try {
822 +                        f.invoke();
823 +                        shouldThrow();
824 +                    } catch (FJException success) {
825 +                        checkCompletedAbnormally(f, success);
826 +                    }
827 +                    f.reinitialize();
828 +                    checkNotDone(f);
829 +                }
830 +            }};
831 +        testInvokeOnPool(mainPool(), a);
832 +    }
833 +
834 +    /**
835       * invoke task throws exception after invoking completeExceptionally
836       */
837      public void testCompleteExceptionally() {
# Line 925 | Line 945 | public class RecursiveActionTest extends
945          testInvokeOnPool(mainPool(), a);
946      }
947  
928
948      /**
949       * invokeAll(tasks) with any null task throws NPE
950       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines