4 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
< |
import static java.util.concurrent.TimeUnit.SECONDS; |
7 |
> |
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
8 |
|
|
9 |
|
import java.util.HashSet; |
10 |
|
import java.util.concurrent.CancellationException; |
69 |
|
|
70 |
|
Thread.currentThread().interrupt(); |
71 |
|
try { |
72 |
< |
a.get(5L, SECONDS); |
72 |
> |
a.get(randomTimeout(), randomTimeUnit()); |
73 |
|
shouldThrow(); |
74 |
|
} catch (InterruptedException success) { |
75 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
76 |
|
} |
77 |
|
|
78 |
|
try { |
79 |
< |
a.get(0L, SECONDS); |
79 |
> |
a.get(randomExpiredTimeout(), randomTimeUnit()); |
80 |
|
shouldThrow(); |
81 |
|
} catch (TimeoutException success) { |
82 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
94 |
|
assertFalse(a.cancel(true)); |
95 |
|
try { |
96 |
|
assertSame(expected, a.get()); |
97 |
< |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
98 |
< |
try { |
99 |
< |
assertSame(expected, a.get(5L, SECONDS)); |
100 |
< |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
97 |
> |
assertSame(expected, a.get(randomTimeout(), randomTimeUnit())); |
98 |
> |
} catch (Exception fail) { threadUnexpectedException(fail); } |
99 |
|
} |
100 |
|
|
101 |
|
/** |
139 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
140 |
|
|
141 |
|
try { |
142 |
< |
a.get(5L, SECONDS); |
142 |
> |
a.get(randomTimeout(), randomTimeUnit()); |
143 |
|
shouldThrow(); |
144 |
|
} catch (CancellationException success) { |
145 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
170 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
171 |
|
|
172 |
|
try { |
173 |
< |
a.get(5L, SECONDS); |
173 |
> |
a.get(randomTimeout(), randomTimeUnit()); |
174 |
|
shouldThrow(); |
175 |
|
} catch (ExecutionException success) { |
176 |
|
assertSame(t.getClass(), success.getCause().getClass()); |
291 |
|
public Integer realCompute() throws Exception { |
292 |
|
FibTask f = new FibTask(8); |
293 |
|
assertSame(f, f.fork()); |
294 |
< |
Integer r = f.get(5L, SECONDS); |
294 |
> |
Integer r = f.get(LONG_DELAY_MS, MILLISECONDS); |
295 |
|
assertEquals(21, (int) r); |
296 |
|
checkCompletedNormally(f, r); |
297 |
|
return r; |
417 |
|
FailingFibTask f = new FailingFibTask(8); |
418 |
|
assertSame(f, f.fork()); |
419 |
|
try { |
420 |
< |
Integer r = f.get(5L, SECONDS); |
420 |
> |
Integer r = f.get(LONG_DELAY_MS, MILLISECONDS); |
421 |
|
shouldThrow(); |
422 |
|
} catch (ExecutionException success) { |
423 |
|
Throwable cause = success.getCause(); |
514 |
|
assertTrue(f.cancel(true)); |
515 |
|
assertSame(f, f.fork()); |
516 |
|
try { |
517 |
< |
Integer r = f.get(5L, SECONDS); |
517 |
> |
Integer r = f.get(LONG_DELAY_MS, MILLISECONDS); |
518 |
|
shouldThrow(); |
519 |
|
} catch (CancellationException success) { |
520 |
|
checkCancelled(f); |