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.18 by jsr166, Thu Sep 16 00:52:49 2010 UTC vs.
Revision 1.28 by jsr166, Wed Dec 1 22:37:51 2010 UTC

# Line 6 | Line 6
6  
7   import junit.framework.*;
8   import java.util.concurrent.CancellationException;
9 + import java.util.concurrent.SynchronousQueue;
10   import java.util.concurrent.ExecutionException;
11   import java.util.concurrent.ForkJoinPool;
12 + import java.util.concurrent.ForkJoinTask;
13   import java.util.concurrent.ForkJoinWorkerThread;
14   import java.util.concurrent.RecursiveAction;
15   import java.util.concurrent.TimeUnit;
16 + import java.util.concurrent.TimeoutException;
17 + import static java.util.concurrent.TimeUnit.SECONDS;
18   import java.util.HashSet;
19  
20   public class RecursiveActionTest extends JSR166TestCase {
# Line 39 | Line 43 | public class RecursiveActionTest extends
43  
44      private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) {
45          try {
46 <            assertFalse(a.isDone());
43 <            assertFalse(a.isCompletedNormally());
44 <            assertFalse(a.isCompletedAbnormally());
45 <            assertFalse(a.isCancelled());
46 <            assertNull(a.getException());
46 >            checkNotDone(a);
47  
48              assertNull(pool.invoke(a));
49  
50 <            assertTrue(a.isDone());
51 <            assertTrue(a.isCompletedNormally());
52 <            assertFalse(a.isCompletedAbnormally());
53 <            assertFalse(a.isCancelled());
54 <            assertNull(a.getException());
50 >            checkCompletedNormally(a);
51          } finally {
52              joinPool(pool);
53          }
54      }
55  
56 +    void checkNotDone(RecursiveAction a) {
57 +        assertFalse(a.isDone());
58 +        assertFalse(a.isCompletedNormally());
59 +        assertFalse(a.isCompletedAbnormally());
60 +        assertFalse(a.isCancelled());
61 +        assertNull(a.getException());
62 +        assertNull(a.getRawResult());
63 +
64 +        if (! ForkJoinTask.inForkJoinPool()) {
65 +            Thread.currentThread().interrupt();
66 +            try {
67 +                a.get();
68 +                shouldThrow();
69 +            } catch (InterruptedException success) {
70 +            } catch (Throwable fail) { threadUnexpectedException(fail); }
71 +
72 +            Thread.currentThread().interrupt();
73 +            try {
74 +                a.get(5L, SECONDS);
75 +                shouldThrow();
76 +            } catch (InterruptedException success) {
77 +            } catch (Throwable fail) { threadUnexpectedException(fail); }
78 +        }
79 +
80 +        try {
81 +            a.get(0L, SECONDS);
82 +            shouldThrow();
83 +        } catch (TimeoutException success) {
84 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
85 +    }
86 +
87 +    void checkCompletedNormally(RecursiveAction a) {
88 +        assertTrue(a.isDone());
89 +        assertFalse(a.isCancelled());
90 +        assertTrue(a.isCompletedNormally());
91 +        assertFalse(a.isCompletedAbnormally());
92 +        assertNull(a.getException());
93 +        assertNull(a.getRawResult());
94 +        assertNull(a.join());
95 +        assertFalse(a.cancel(false));
96 +        assertFalse(a.cancel(true));
97 +        try {
98 +            assertNull(a.get());
99 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
100 +        try {
101 +            assertNull(a.get(5L, SECONDS));
102 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
103 +    }
104 +
105 +    void checkCancelled(RecursiveAction a) {
106 +        assertTrue(a.isDone());
107 +        assertTrue(a.isCancelled());
108 +        assertFalse(a.isCompletedNormally());
109 +        assertTrue(a.isCompletedAbnormally());
110 +        assertTrue(a.getException() instanceof CancellationException);
111 +        assertNull(a.getRawResult());
112 +
113 +        try {
114 +            a.join();
115 +            shouldThrow();
116 +        } catch (CancellationException success) {
117 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
118 +
119 +        try {
120 +            a.get();
121 +            shouldThrow();
122 +        } catch (CancellationException success) {
123 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
124 +
125 +        try {
126 +            a.get(5L, SECONDS);
127 +            shouldThrow();
128 +        } catch (CancellationException success) {
129 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
130 +    }
131 +
132 +    void checkCompletedAbnormally(RecursiveAction a, Throwable t) {
133 +        assertTrue(a.isDone());
134 +        assertFalse(a.isCancelled());
135 +        assertFalse(a.isCompletedNormally());
136 +        assertTrue(a.isCompletedAbnormally());
137 +        assertSame(t, a.getException());
138 +        assertNull(a.getRawResult());
139 +        assertFalse(a.cancel(false));
140 +        assertFalse(a.cancel(true));
141 +
142 +        try {
143 +            a.join();
144 +            shouldThrow();
145 +        } catch (Throwable expected) {
146 +            assertSame(t, expected);
147 +        }
148 +
149 +        try {
150 +            a.get();
151 +            shouldThrow();
152 +        } catch (ExecutionException success) {
153 +            assertSame(t, success.getCause());
154 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
155 +
156 +        try {
157 +            a.get(5L, SECONDS);
158 +            shouldThrow();
159 +        } catch (ExecutionException success) {
160 +            assertSame(t, success.getCause());
161 +        } catch (Throwable fail) { threadUnexpectedException(fail); }
162 +    }
163 +
164      static final class FJException extends RuntimeException {
165          FJException() { super(); }
166      }
# Line 108 | Line 212 | public class RecursiveActionTest extends
212                  FibAction f = new FibAction(8);
213                  assertNull(f.invoke());
214                  assertEquals(21, f.result);
215 <                assertTrue(f.isDone());
112 <                assertFalse(f.isCancelled());
113 <                assertFalse(f.isCompletedAbnormally());
114 <                assertNull(f.getRawResult());
215 >                checkCompletedNormally(f);
216              }};
217          testInvokeOnPool(mainPool(), a);
218      }
# Line 127 | Line 228 | public class RecursiveActionTest extends
228                  FibAction f = new FibAction(8);
229                  f.quietlyInvoke();
230                  assertEquals(21, f.result);
231 <                assertTrue(f.isDone());
131 <                assertFalse(f.isCancelled());
132 <                assertFalse(f.isCompletedAbnormally());
133 <                assertNull(f.getRawResult());
231 >                checkCompletedNormally(f);
232              }};
233          testInvokeOnPool(mainPool(), a);
234      }
# Line 145 | Line 243 | public class RecursiveActionTest extends
243                  assertSame(f, f.fork());
244                  assertNull(f.join());
245                  assertEquals(21, f.result);
246 <                assertTrue(f.isDone());
247 <                assertNull(f.getRawResult());
246 >                checkCompletedNormally(f);
247 >            }};
248 >        testInvokeOnPool(mainPool(), a);
249 >    }
250 >
251 >    /**
252 >     * join/quietlyJoin of a forked task succeeds in the presence of interrupts
253 >     */
254 >    public void testJoinIgnoresInterrupts() {
255 >        RecursiveAction a = new CheckedRecursiveAction() {
256 >            public void realCompute() {
257 >                FibAction f = new FibAction(8);
258 >                final Thread myself = Thread.currentThread();
259 >
260 >                // test join()
261 >                assertSame(f, f.fork());
262 >                myself.interrupt();
263 >                assertTrue(myself.isInterrupted());
264 >                assertNull(f.join());
265 >                Thread.interrupted();
266 >                assertEquals(21, f.result);
267 >                checkCompletedNormally(f);
268 >
269 >                f.reinitialize();
270 >                f.cancel(true);
271 >                assertSame(f, f.fork());
272 >                myself.interrupt();
273 >                assertTrue(myself.isInterrupted());
274 >                try {
275 >                    f.join();
276 >                    shouldThrow();
277 >                } catch (CancellationException success) {
278 >                    Thread.interrupted();
279 >                    checkCancelled(f);
280 >                }
281 >
282 >                f.reinitialize();
283 >                f.completeExceptionally(new FJException());
284 >                assertSame(f, f.fork());
285 >                myself.interrupt();
286 >                assertTrue(myself.isInterrupted());
287 >                try {
288 >                    f.join();
289 >                    shouldThrow();
290 >                } catch (FJException success) {
291 >                    Thread.interrupted();
292 >                    checkCompletedAbnormally(f, success);
293 >                }
294 >
295 >                // test quietlyJoin()
296 >                f.reinitialize();
297 >                assertSame(f, f.fork());
298 >                myself.interrupt();
299 >                assertTrue(myself.isInterrupted());
300 >                f.quietlyJoin();
301 >                Thread.interrupted();
302 >                assertEquals(21, f.result);
303 >                checkCompletedNormally(f);
304 >
305 >                f.reinitialize();
306 >                f.cancel(true);
307 >                assertSame(f, f.fork());
308 >                myself.interrupt();
309 >                assertTrue(myself.isInterrupted());
310 >                f.quietlyJoin();
311 >                Thread.interrupted();
312 >                checkCancelled(f);
313 >
314 >                f.reinitialize();
315 >                f.completeExceptionally(new FJException());
316 >                assertSame(f, f.fork());
317 >                myself.interrupt();
318 >                assertTrue(myself.isInterrupted());
319 >                f.quietlyJoin();
320 >                Thread.interrupted();
321 >                checkCompletedAbnormally(f, f.getException());
322 >            }};
323 >        testInvokeOnPool(mainPool(), a);
324 >        a.reinitialize();
325 >        testInvokeOnPool(singletonPool(), a);
326 >    }
327 >
328 >    /**
329 >     * join/quietlyJoin of a forked task when not in ForkJoinPool
330 >     * succeeds in the presence of interrupts
331 >     */
332 >    public void testJoinIgnoresInterruptsOutsideForkJoinPool() {
333 >        final SynchronousQueue<FibAction[]> sq =
334 >            new SynchronousQueue<FibAction[]>();
335 >        RecursiveAction a = new CheckedRecursiveAction() {
336 >            public void realCompute() throws InterruptedException {
337 >                FibAction[] fibActions = new FibAction[6];
338 >                for (int i = 0; i < fibActions.length; i++)
339 >                    fibActions[i] = new FibAction(8);
340 >
341 >                fibActions[1].cancel(false);
342 >                fibActions[2].completeExceptionally(new FJException());
343 >                fibActions[4].cancel(true);
344 >                fibActions[5].completeExceptionally(new FJException());
345 >
346 >                for (int i = 0; i < fibActions.length; i++)
347 >                    fibActions[i].fork();
348 >
349 >                sq.put(fibActions);
350 >
351 >                helpQuiesce();
352 >            }};
353 >
354 >        Runnable r = new CheckedRunnable() {
355 >            public void realRun() throws InterruptedException {
356 >                FibAction[] fibActions = sq.take();
357 >                FibAction f;
358 >                final Thread myself = Thread.currentThread();
359 >
360 >                // test join() ------------
361 >
362 >                f = fibActions[0];
363 >                assertFalse(ForkJoinTask.inForkJoinPool());
364 >                myself.interrupt();
365 >                assertTrue(myself.isInterrupted());
366 >                assertNull(f.join());
367 >                assertTrue(Thread.interrupted());
368 >                assertEquals(21, f.result);
369 >                checkCompletedNormally(f);
370 >
371 >                f = fibActions[1];
372 >                myself.interrupt();
373 >                assertTrue(myself.isInterrupted());
374 >                try {
375 >                    f.join();
376 >                    shouldThrow();
377 >                } catch (CancellationException success) {
378 >                    assertTrue(Thread.interrupted());
379 >                    checkCancelled(f);
380 >                }
381 >
382 >                f = fibActions[2];
383 >                myself.interrupt();
384 >                assertTrue(myself.isInterrupted());
385 >                try {
386 >                    f.join();
387 >                    shouldThrow();
388 >                } catch (FJException success) {
389 >                    assertTrue(Thread.interrupted());
390 >                    checkCompletedAbnormally(f, success);
391 >                }
392 >
393 >                // test quietlyJoin() ---------
394 >
395 >                f = fibActions[3];
396 >                myself.interrupt();
397 >                assertTrue(myself.isInterrupted());
398 >                f.quietlyJoin();
399 >                assertTrue(Thread.interrupted());
400 >                assertEquals(21, f.result);
401 >                checkCompletedNormally(f);
402 >
403 >                f = fibActions[4];
404 >                myself.interrupt();
405 >                assertTrue(myself.isInterrupted());
406 >                f.quietlyJoin();
407 >                assertTrue(Thread.interrupted());
408 >                checkCancelled(f);
409 >
410 >                f = fibActions[5];
411 >                myself.interrupt();
412 >                assertTrue(myself.isInterrupted());
413 >                f.quietlyJoin();
414 >                assertTrue(Thread.interrupted());
415 >                assertTrue(f.getException() instanceof FJException);
416 >                checkCompletedAbnormally(f, f.getException());
417              }};
418 +
419 +        Thread t;
420 +
421 +        t = newStartedThread(r);
422          testInvokeOnPool(mainPool(), a);
423 +        awaitTermination(t, LONG_DELAY_MS);
424 +
425 +        a.reinitialize();
426 +        t = newStartedThread(r);
427 +        testInvokeOnPool(singletonPool(), a);
428 +        awaitTermination(t, LONG_DELAY_MS);
429      }
430  
431      /**
# Line 161 | Line 438 | public class RecursiveActionTest extends
438                  assertSame(f, f.fork());
439                  assertNull(f.get());
440                  assertEquals(21, f.result);
441 <                assertTrue(f.isDone());
441 >                checkCompletedNormally(f);
442              }};
443          testInvokeOnPool(mainPool(), a);
444      }
# Line 174 | Line 451 | public class RecursiveActionTest extends
451              public void realCompute() throws Exception {
452                  FibAction f = new FibAction(8);
453                  assertSame(f, f.fork());
454 <                assertNull(f.get(5L, TimeUnit.SECONDS));
454 >                assertNull(f.get(5L, SECONDS));
455                  assertEquals(21, f.result);
456 <                assertTrue(f.isDone());
456 >                checkCompletedNormally(f);
457              }};
458          testInvokeOnPool(mainPool(), a);
459      }
# Line 207 | Line 484 | public class RecursiveActionTest extends
484                  assertSame(f, f.fork());
485                  f.quietlyJoin();
486                  assertEquals(21, f.result);
487 <                assertTrue(f.isDone());
487 >                checkCompletedNormally(f);
488              }};
489          testInvokeOnPool(mainPool(), a);
490      }
# Line 224 | Line 501 | public class RecursiveActionTest extends
501                  assertSame(f, f.fork());
502                  f.helpQuiesce();
503                  assertEquals(21, f.result);
227                assertTrue(f.isDone());
504                  assertEquals(0, getQueuedTaskCount());
505 +                checkCompletedNormally(f);
506              }};
507          testInvokeOnPool(mainPool(), a);
508      }
# Line 241 | Line 518 | public class RecursiveActionTest extends
518                  try {
519                      f.invoke();
520                      shouldThrow();
521 <                } catch (FJException success) {}
521 >                } catch (FJException success) {
522 >                    checkCompletedAbnormally(f, success);
523 >                }
524              }};
525          testInvokeOnPool(mainPool(), a);
526      }
# Line 254 | Line 533 | public class RecursiveActionTest extends
533              public void realCompute() {
534                  FailingFibAction f = new FailingFibAction(8);
535                  f.quietlyInvoke();
536 <                assertTrue(f.isDone());
536 >                assertTrue(f.getException() instanceof FJException);
537 >                checkCompletedAbnormally(f, f.getException());
538              }};
539          testInvokeOnPool(mainPool(), a);
540      }
# Line 270 | Line 550 | public class RecursiveActionTest extends
550                  try {
551                      f.join();
552                      shouldThrow();
553 <                } catch (FJException success) {}
553 >                } catch (FJException success) {
554 >                    checkCompletedAbnormally(f, success);
555 >                }
556              }};
557          testInvokeOnPool(mainPool(), a);
558      }
# Line 286 | Line 568 | public class RecursiveActionTest extends
568                  try {
569                      f.get();
570                      shouldThrow();
571 <                } catch (ExecutionException success) {}
571 >                } catch (ExecutionException success) {
572 >                    Throwable cause = success.getCause();
573 >                    assertTrue(cause instanceof FJException);
574 >                    checkCompletedAbnormally(f, cause);
575 >                }
576              }};
577          testInvokeOnPool(mainPool(), a);
578      }
# Line 302 | Line 588 | public class RecursiveActionTest extends
588                  try {
589                      f.get(5L, TimeUnit.SECONDS);
590                      shouldThrow();
591 <                } catch (ExecutionException success) {}
591 >                } catch (ExecutionException success) {
592 >                    Throwable cause = success.getCause();
593 >                    assertTrue(cause instanceof FJException);
594 >                    checkCompletedAbnormally(f, cause);
595 >                }
596              }};
597          testInvokeOnPool(mainPool(), a);
598      }
# Line 316 | Line 606 | public class RecursiveActionTest extends
606                  FailingFibAction f = new FailingFibAction(8);
607                  assertSame(f, f.fork());
608                  f.quietlyJoin();
319                assertTrue(f.isDone());
320                assertTrue(f.isCompletedAbnormally());
609                  assertTrue(f.getException() instanceof FJException);
610 +                checkCompletedAbnormally(f, f.getException());
611              }};
612          testInvokeOnPool(mainPool(), a);
613      }
# Line 334 | Line 623 | public class RecursiveActionTest extends
623                  try {
624                      f.invoke();
625                      shouldThrow();
626 <                } catch (CancellationException success) {}
626 >                } catch (CancellationException success) {
627 >                    checkCancelled(f);
628 >                }
629              }};
630          testInvokeOnPool(mainPool(), a);
631      }
# Line 351 | Line 642 | public class RecursiveActionTest extends
642                  try {
643                      f.join();
644                      shouldThrow();
645 <                } catch (CancellationException success) {}
645 >                } catch (CancellationException success) {
646 >                    checkCancelled(f);
647 >                }
648              }};
649          testInvokeOnPool(mainPool(), a);
650      }
# Line 368 | Line 661 | public class RecursiveActionTest extends
661                  try {
662                      f.get();
663                      shouldThrow();
664 <                } catch (CancellationException success) {}
664 >                } catch (CancellationException success) {
665 >                    checkCancelled(f);
666 >                }
667              }};
668          testInvokeOnPool(mainPool(), a);
669      }
# Line 383 | Line 678 | public class RecursiveActionTest extends
678                  assertTrue(f.cancel(true));
679                  assertSame(f, f.fork());
680                  try {
681 <                    f.get(5L, TimeUnit.SECONDS);
681 >                    f.get(5L, SECONDS);
682                      shouldThrow();
683 <                } catch (CancellationException success) {}
683 >                } catch (CancellationException success) {
684 >                    checkCancelled(f);
685 >                }
686              }};
687          testInvokeOnPool(mainPool(), a);
688      }
# Line 400 | Line 697 | public class RecursiveActionTest extends
697                  assertTrue(f.cancel(true));
698                  assertSame(f, f.fork());
699                  f.quietlyJoin();
700 <                assertTrue(f.isDone());
404 <                assertTrue(f.isCompletedAbnormally());
405 <                assertTrue(f.isCancelled());
406 <                assertTrue(f.getException() instanceof CancellationException);
700 >                checkCancelled(f);
701              }};
702          testInvokeOnPool(mainPool(), a);
703      }
# Line 475 | Line 769 | public class RecursiveActionTest extends
769          RecursiveAction a = new CheckedRecursiveAction() {
770              public void realCompute() {
771                  ForkJoinWorkerThread w =
772 <                    (ForkJoinWorkerThread)(Thread.currentThread());
773 <                int idx = w.getPoolIndex();
774 <                assertTrue(idx >= 0);
481 <                assertTrue(idx < mainPool.getPoolSize());
772 >                    (ForkJoinWorkerThread) Thread.currentThread();
773 >                assertTrue(w.getPoolIndex() >= 0);
774 >                assertTrue(w.getPoolIndex() < mainPool.getPoolSize());
775              }};
776          testInvokeOnPool(mainPool, a);
777      }
# Line 491 | Line 784 | public class RecursiveActionTest extends
784          RecursiveAction a = new CheckedRecursiveAction() {
785              public void realCompute() {
786                  setRawResult(null);
787 +                assertNull(getRawResult());
788              }};
789          assertNull(a.invoke());
790      }
# Line 502 | Line 796 | public class RecursiveActionTest extends
796          RecursiveAction a = new CheckedRecursiveAction() {
797              public void realCompute() {
798                  FibAction f = new FibAction(8);
799 <                assertNull(f.invoke());
800 <                assertEquals(21, f.result);
801 <                assertTrue(f.isDone());
802 <                assertFalse(f.isCancelled());
803 <                assertFalse(f.isCompletedAbnormally());
804 <                f.reinitialize();
805 <                assertNull(f.invoke());
806 <                assertEquals(21, f.result);
799 >                checkNotDone(f);
800 >
801 >                for (int i = 0; i < 3; i++) {
802 >                    assertNull(f.invoke());
803 >                    assertEquals(21, f.result);
804 >                    checkCompletedNormally(f);
805 >                    f.reinitialize();
806 >                    checkNotDone(f);
807 >                }
808              }};
809          testInvokeOnPool(mainPool(), a);
810      }
# Line 525 | Line 820 | public class RecursiveActionTest extends
820                  try {
821                      f.invoke();
822                      shouldThrow();
823 <                } catch (FJException success) {}
823 >                } catch (FJException success) {
824 >                    checkCompletedAbnormally(f, success);
825 >                }
826              }};
827          testInvokeOnPool(mainPool(), a);
828      }
# Line 539 | Line 836 | public class RecursiveActionTest extends
836                  FibAction f = new FibAction(8);
837                  f.complete(null);
838                  assertNull(f.invoke());
542                assertTrue(f.isDone());
839                  assertEquals(0, f.result);
840 +                checkCompletedNormally(f);
841              }};
842          testInvokeOnPool(mainPool(), a);
843      }
# Line 554 | Line 851 | public class RecursiveActionTest extends
851                  FibAction f = new FibAction(8);
852                  FibAction g = new FibAction(9);
853                  invokeAll(f, g);
854 <                assertTrue(f.isDone());
854 >                checkCompletedNormally(f);
855                  assertEquals(21, f.result);
856 <                assertTrue(g.isDone());
856 >                checkCompletedNormally(g);
857                  assertEquals(34, g.result);
858              }};
859          testInvokeOnPool(mainPool(), a);
# Line 570 | Line 867 | public class RecursiveActionTest extends
867              public void realCompute() {
868                  FibAction f = new FibAction(8);
869                  invokeAll(f);
870 <                assertTrue(f.isDone());
870 >                checkCompletedNormally(f);
871                  assertEquals(21, f.result);
872              }};
873          testInvokeOnPool(mainPool(), a);
# Line 587 | Line 884 | public class RecursiveActionTest extends
884                  FibAction h = new FibAction(7);
885                  invokeAll(f, g, h);
886                  assertTrue(f.isDone());
590                assertEquals(21, f.result);
887                  assertTrue(g.isDone());
592                assertEquals(34, g.result);
888                  assertTrue(h.isDone());
889 +                checkCompletedNormally(f);
890 +                assertEquals(21, f.result);
891 +                checkCompletedNormally(g);
892 +                assertEquals(34, g.result);
893 +                checkCompletedNormally(g);
894                  assertEquals(13, h.result);
895              }};
896          testInvokeOnPool(mainPool(), a);
# Line 611 | Line 911 | public class RecursiveActionTest extends
911                  set.add(h);
912                  invokeAll(set);
913                  assertTrue(f.isDone());
614                assertEquals(21, f.result);
914                  assertTrue(g.isDone());
616                assertEquals(34, g.result);
915                  assertTrue(h.isDone());
916 +                checkCompletedNormally(f);
917 +                assertEquals(21, f.result);
918 +                checkCompletedNormally(g);
919 +                assertEquals(34, g.result);
920 +                checkCompletedNormally(g);
921                  assertEquals(13, h.result);
922              }};
923          testInvokeOnPool(mainPool(), a);
# Line 649 | Line 952 | public class RecursiveActionTest extends
952                  try {
953                      invokeAll(f, g);
954                      shouldThrow();
955 <                } catch (FJException success) {}
955 >                } catch (FJException success) {
956 >                    checkCompletedAbnormally(g, success);
957 >                }
958              }};
959          testInvokeOnPool(mainPool(), a);
960      }
# Line 664 | Line 969 | public class RecursiveActionTest extends
969                  try {
970                      invokeAll(g);
971                      shouldThrow();
972 <                } catch (FJException success) {}
972 >                } catch (FJException success) {
973 >                    checkCompletedAbnormally(g, success);
974 >                }
975              }};
976          testInvokeOnPool(mainPool(), a);
977      }
# Line 681 | Line 988 | public class RecursiveActionTest extends
988                  try {
989                      invokeAll(f, g, h);
990                      shouldThrow();
991 <                } catch (FJException success) {}
991 >                } catch (FJException success) {
992 >                    checkCompletedAbnormally(g, success);
993 >                }
994              }};
995          testInvokeOnPool(mainPool(), a);
996      }
# Line 702 | Line 1011 | public class RecursiveActionTest extends
1011                  try {
1012                      invokeAll(set);
1013                      shouldThrow();
1014 <                } catch (FJException success) {}
1014 >                } catch (FJException success) {
1015 >                    checkCompletedAbnormally(f, success);
1016 >                }
1017              }};
1018          testInvokeOnPool(mainPool(), a);
1019      }
# Line 720 | Line 1031 | public class RecursiveActionTest extends
1031                  assertSame(f, f.fork());
1032                  assertTrue(f.tryUnfork());
1033                  helpQuiesce();
1034 <                assertFalse(f.isDone());
1035 <                assertTrue(g.isDone());
1034 >                checkNotDone(f);
1035 >                checkCompletedNormally(g);
1036              }};
1037          testInvokeOnPool(singletonPool(), a);
1038      }
# Line 741 | Line 1052 | public class RecursiveActionTest extends
1052                  assertSame(f, f.fork());
1053                  assertTrue(getSurplusQueuedTaskCount() > 0);
1054                  helpQuiesce();
1055 +                assertEquals(0, getSurplusQueuedTaskCount());
1056 +                checkCompletedNormally(f);
1057 +                checkCompletedNormally(g);
1058 +                checkCompletedNormally(h);
1059              }};
1060          testInvokeOnPool(singletonPool(), a);
1061      }
# Line 757 | Line 1072 | public class RecursiveActionTest extends
1072                  assertSame(f, f.fork());
1073                  assertSame(f, peekNextLocalTask());
1074                  assertNull(f.join());
1075 <                assertTrue(f.isDone());
1075 >                checkCompletedNormally(f);
1076                  helpQuiesce();
1077 +                checkCompletedNormally(f);
1078 +                checkCompletedNormally(g);
1079              }};
1080          testInvokeOnPool(singletonPool(), a);
1081      }
# Line 776 | Line 1093 | public class RecursiveActionTest extends
1093                  assertSame(f, f.fork());
1094                  assertSame(f, pollNextLocalTask());
1095                  helpQuiesce();
1096 <                assertFalse(f.isDone());
1096 >                checkNotDone(f);
1097 >                checkCompletedNormally(g);
1098              }};
1099          testInvokeOnPool(singletonPool(), a);
1100      }
1101  
1102      /**
1103 <     * pollTask returns an unexecuted task
786 <     * without executing it
1103 >     * pollTask returns an unexecuted task without executing it
1104       */
1105      public void testPollTask() {
1106          RecursiveAction a = new CheckedRecursiveAction() {
# Line 794 | Line 1111 | public class RecursiveActionTest extends
1111                  assertSame(f, f.fork());
1112                  assertSame(f, pollTask());
1113                  helpQuiesce();
1114 <                assertFalse(f.isDone());
1115 <                assertTrue(g.isDone());
1114 >                checkNotDone(f);
1115 >                checkCompletedNormally(g);
1116              }};
1117          testInvokeOnPool(singletonPool(), a);
1118      }
# Line 813 | Line 1130 | public class RecursiveActionTest extends
1130                  assertSame(g, peekNextLocalTask());
1131                  assertNull(f.join());
1132                  helpQuiesce();
1133 <                assertTrue(f.isDone());
1133 >                checkCompletedNormally(f);
1134 >                checkCompletedNormally(g);
1135              }};
1136          testInvokeOnPool(asyncSingletonPool(), a);
1137      }
1138  
1139      /**
1140 <     * pollNextLocalTask returns least recent unexecuted task
1141 <     * without executing it, in async mode
1140 >     * pollNextLocalTask returns least recent unexecuted task without
1141 >     * executing it, in async mode
1142       */
1143      public void testPollNextLocalTaskAsync() {
1144          RecursiveAction a = new CheckedRecursiveAction() {
# Line 831 | Line 1149 | public class RecursiveActionTest extends
1149                  assertSame(f, f.fork());
1150                  assertSame(g, pollNextLocalTask());
1151                  helpQuiesce();
1152 <                assertTrue(f.isDone());
1153 <                assertFalse(g.isDone());
1152 >                checkCompletedNormally(f);
1153 >                checkNotDone(g);
1154              }};
1155          testInvokeOnPool(asyncSingletonPool(), a);
1156      }
1157  
1158      /**
1159 <     * pollTask returns an unexecuted task
1160 <     * without executing it, in async mode
1159 >     * pollTask returns an unexecuted task without executing it, in
1160 >     * async mode
1161       */
1162      public void testPollTaskAsync() {
1163          RecursiveAction a = new CheckedRecursiveAction() {
# Line 850 | Line 1168 | public class RecursiveActionTest extends
1168                  assertSame(f, f.fork());
1169                  assertSame(g, pollTask());
1170                  helpQuiesce();
1171 <                assertTrue(f.isDone());
1172 <                assertFalse(g.isDone());
1171 >                checkCompletedNormally(f);
1172 >                checkNotDone(g);
1173              }};
1174          testInvokeOnPool(asyncSingletonPool(), a);
1175      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines