11 |
|
public class ForkJoinTaskTest extends JSR166TestCase { |
12 |
|
|
13 |
|
public static void main(String[] args) { |
14 |
< |
junit.textui.TestRunner.run (suite()); |
14 |
> |
junit.textui.TestRunner.run (suite()); |
15 |
|
} |
16 |
|
public static Test suite() { |
17 |
< |
return new TestSuite(ForkJoinTaskTest.class); |
17 |
> |
return new TestSuite(ForkJoinTaskTest.class); |
18 |
|
} |
19 |
|
|
20 |
|
/** |
148 |
|
|
149 |
|
} |
150 |
|
|
151 |
< |
static final class AsyncFib extends BinaryAsyncAction { |
151 |
> |
static final class AsyncFib extends BinaryAsyncAction { |
152 |
|
int number; |
153 |
|
public AsyncFib(int n) { |
154 |
|
this.number = n; |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
< |
static final class FailingAsyncFib extends BinaryAsyncAction { |
180 |
> |
static final class FailingAsyncFib extends BinaryAsyncAction { |
181 |
|
int number; |
182 |
|
public FailingAsyncFib(int n) { |
183 |
|
this.number = n; |
276 |
|
threadAssertTrue(f.number == 21); |
277 |
|
threadAssertTrue(f.isDone()); |
278 |
|
} catch (Exception ex) { |
279 |
< |
unexpectedException(); |
279 |
> |
unexpectedException(ex); |
280 |
|
} |
281 |
|
} |
282 |
|
}; |
292 |
|
try { |
293 |
|
AsyncFib f = new AsyncFib(8); |
294 |
|
f.fork(); |
295 |
< |
f.get(5L, TimeUnit.SECONDS); |
295 |
> |
f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS); |
296 |
|
threadAssertTrue(f.number == 21); |
297 |
|
threadAssertTrue(f.isDone()); |
298 |
|
} catch (Exception ex) { |
299 |
< |
unexpectedException(); |
299 |
> |
unexpectedException(ex); |
300 |
|
} |
301 |
|
} |
302 |
|
}; |
313 |
|
AsyncFib f = new AsyncFib(8); |
314 |
|
f.fork(); |
315 |
|
f.get(5L, null); |
316 |
+ |
shouldThrow(); |
317 |
|
} catch (NullPointerException success) { |
318 |
|
} catch (Exception ex) { |
319 |
< |
unexpectedException(); |
319 |
> |
unexpectedException(ex); |
320 |
|
} |
321 |
|
} |
322 |
|
}; |
452 |
|
f.fork(); |
453 |
|
f.get(); |
454 |
|
shouldThrow(); |
455 |
< |
} catch (Exception success) { |
455 |
> |
} catch (ExecutionException success) { |
456 |
> |
} catch (Exception ex) { |
457 |
> |
unexpectedException(ex); |
458 |
|
} |
459 |
|
} |
460 |
|
}; |
470 |
|
try { |
471 |
|
FailingAsyncFib f = new FailingAsyncFib(8); |
472 |
|
f.fork(); |
473 |
< |
f.get(5L, TimeUnit.SECONDS); |
473 |
> |
f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS); |
474 |
|
shouldThrow(); |
475 |
< |
} catch (Exception success) { |
475 |
> |
} catch (ExecutionException success) { |
476 |
> |
} catch (Exception ex) { |
477 |
> |
unexpectedException(ex); |
478 |
|
} |
479 |
|
} |
480 |
|
}; |
586 |
|
f.fork(); |
587 |
|
f.get(); |
588 |
|
shouldThrow(); |
589 |
< |
} catch (Exception success) { |
589 |
> |
} catch (CancellationException success) { |
590 |
> |
} catch (Exception ex) { |
591 |
> |
unexpectedException(ex); |
592 |
|
} |
593 |
|
} |
594 |
|
}; |
605 |
|
AsyncFib f = new AsyncFib(8); |
606 |
|
f.cancel(true); |
607 |
|
f.fork(); |
608 |
< |
f.get(5L, TimeUnit.SECONDS); |
608 |
> |
f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS); |
609 |
|
shouldThrow(); |
610 |
< |
} catch (Exception success) { |
610 |
> |
} catch (CancellationException success) { |
611 |
> |
} catch (Exception ex) { |
612 |
> |
unexpectedException(ex); |
613 |
|
} |
614 |
|
} |
615 |
|
}; |