5 |
|
*/ |
6 |
|
|
7 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
8 |
– |
import static java.util.concurrent.TimeUnit.SECONDS; |
8 |
|
|
9 |
|
import java.util.HashSet; |
10 |
|
import java.util.concurrent.CancellationException; |
76 |
|
assertNull(a.getRawResult()); |
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 |
|
Thread.currentThread().interrupt(); |
95 |
|
long startTime = System.nanoTime(); |
96 |
|
assertNull(a.join()); |
97 |
< |
assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS); |
97 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
98 |
|
Thread.interrupted(); |
99 |
|
} |
100 |
|
|
102 |
|
Thread.currentThread().interrupt(); |
103 |
|
long startTime = System.nanoTime(); |
104 |
|
a.quietlyJoin(); // should be no-op |
105 |
< |
assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS); |
105 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
106 |
|
Thread.interrupted(); |
107 |
|
} |
108 |
|
|
110 |
|
assertFalse(a.cancel(true)); |
111 |
|
try { |
112 |
|
assertNull(a.get()); |
113 |
< |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
115 |
< |
try { |
116 |
< |
assertNull(a.get(5L, SECONDS)); |
113 |
> |
assertNull(a.get(randomTimeout(), randomTimeUnit())); |
114 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
115 |
|
} |
116 |
|
|
135 |
|
{ |
136 |
|
long startTime = System.nanoTime(); |
137 |
|
a.quietlyJoin(); // should be no-op |
138 |
< |
assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS); |
138 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
139 |
|
} |
140 |
|
|
141 |
|
try { |
145 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
146 |
|
|
147 |
|
try { |
148 |
< |
a.get(5L, SECONDS); |
148 |
> |
a.get(randomTimeout(), randomTimeUnit()); |
149 |
|
shouldThrow(); |
150 |
|
} catch (CancellationException success) { |
151 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
173 |
|
{ |
174 |
|
long startTime = System.nanoTime(); |
175 |
|
a.quietlyJoin(); // should be no-op |
176 |
< |
assertTrue(millisElapsedSince(startTime) < SMALL_DELAY_MS); |
176 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
177 |
|
} |
178 |
|
|
179 |
|
try { |
184 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
185 |
|
|
186 |
|
try { |
187 |
< |
a.get(5L, SECONDS); |
187 |
> |
a.get(randomTimeout(), randomTimeUnit()); |
188 |
|
shouldThrow(); |
189 |
|
} catch (ExecutionException success) { |
190 |
|
assertSame(t.getClass(), success.getCause().getClass()); |
699 |
|
CCF f = new LCCF(8); |
700 |
|
assertSame(f, f.fork()); |
701 |
|
try { |
702 |
< |
f.get(5L, null); |
702 |
> |
f.get(randomTimeout(), null); |
703 |
|
shouldThrow(); |
704 |
|
} catch (NullPointerException success) {} |
705 |
|
}}; |
1421 |
|
CCF f = new LCCF(8); |
1422 |
|
assertSame(f, f.fork()); |
1423 |
|
try { |
1424 |
< |
f.get(5L, null); |
1424 |
> |
f.get(randomTimeout(), null); |
1425 |
|
shouldThrow(); |
1426 |
|
} catch (NullPointerException success) {} |
1427 |
|
}}; |