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.21 by jsr166, Sun Nov 21 19:06:53 2010 UTC vs.
Revision 1.25 by jsr166, Tue Nov 23 06:33:26 2010 UTC

# Line 90 | Line 90 | public class RecursiveActionTest extends
90          assertNull(a.getException());
91          assertNull(a.getRawResult());
92          assertNull(a.join());
93 +        assertFalse(a.cancel(false));
94 +        assertFalse(a.cancel(true));
95          try {
96              assertNull(a.get());
97          } catch (Throwable fail) { threadUnexpectedException(fail); }
# Line 132 | Line 134 | public class RecursiveActionTest extends
134          assertTrue(a.isCompletedAbnormally());
135          assertSame(t, a.getException());
136          assertNull(a.getRawResult());
137 +        assertFalse(a.cancel(false));
138 +        assertFalse(a.cancel(true));
139  
140          try {
141              a.join();
# Line 243 | Line 247 | public class RecursiveActionTest extends
247      }
248  
249      /**
250 +     * join/quietlyJoin of a forked task succeeds in the presence of interrupts
251 +     */
252 +    public void testJoinIgnoresInterrupts() {
253 +        RecursiveAction a = new CheckedRecursiveAction() {
254 +            public void realCompute() {
255 +                FibAction f = new FibAction(8);
256 +
257 +                // test join()
258 +                assertSame(f, f.fork());
259 +                Thread.currentThread().interrupt();
260 +                assertNull(f.join());
261 +                Thread.interrupted();
262 +                assertEquals(21, f.result);
263 +                checkCompletedNormally(f);
264 +
265 +                f.reinitialize();
266 +                f.cancel(true);
267 +                assertSame(f, f.fork());
268 +                Thread.currentThread().interrupt();
269 +                try {
270 +                    f.join();
271 +                    shouldThrow();
272 +                } catch (CancellationException success) {
273 +                    Thread.interrupted();
274 +                    checkCancelled(f);
275 +                }
276 +
277 +                f.reinitialize();
278 +                f.completeExceptionally(new FJException());
279 +                assertSame(f, f.fork());
280 +                Thread.currentThread().interrupt();
281 +                try {
282 +                    f.join();
283 +                    shouldThrow();
284 +                } catch (FJException success) {
285 +                    Thread.interrupted();
286 +                    checkCompletedAbnormally(f, success);
287 +                }
288 +
289 +                // test quietlyJoin()
290 +                f.reinitialize();
291 +                assertSame(f, f.fork());
292 +                Thread.currentThread().interrupt();
293 +                f.quietlyJoin();
294 +                Thread.interrupted();
295 +                assertEquals(21, f.result);
296 +                checkCompletedNormally(f);
297 +
298 +                f.reinitialize();
299 +                f.cancel(true);
300 +                assertSame(f, f.fork());
301 +                Thread.currentThread().interrupt();
302 +                f.quietlyJoin();
303 +                Thread.interrupted();
304 +                checkCancelled(f);
305 +
306 +                f.reinitialize();
307 +                f.completeExceptionally(new FJException());
308 +                assertSame(f, f.fork());
309 +                Thread.currentThread().interrupt();
310 +                f.quietlyJoin();
311 +                Thread.interrupted();
312 +                checkCompletedAbnormally(f, f.getException());
313 +            }};
314 +        testInvokeOnPool(mainPool(), a);
315 +        a.reinitialize();
316 +        testInvokeOnPool(singletonPool(), a);
317 +    }
318 +
319 +    /**
320       * get of a forked task returns when task completes
321       */
322      public void testForkGet() {
# Line 598 | Line 672 | public class RecursiveActionTest extends
672          RecursiveAction a = new CheckedRecursiveAction() {
673              public void realCompute() {
674                  setRawResult(null);
675 +                assertNull(getRawResult());
676              }};
677          assertNull(a.invoke());
678      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines