1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
import junit.framework.*; |
134 |
|
assertFalse(a.isCancelled()); |
135 |
|
assertFalse(a.isCompletedNormally()); |
136 |
|
assertTrue(a.isCompletedAbnormally()); |
137 |
< |
assertSame(t, a.getException()); |
137 |
> |
assertSame(t.getClass(), a.getException().getClass()); |
138 |
|
assertNull(a.getRawResult()); |
139 |
|
assertFalse(a.cancel(false)); |
140 |
|
assertFalse(a.cancel(true)); |
143 |
|
a.join(); |
144 |
|
shouldThrow(); |
145 |
|
} catch (Throwable expected) { |
146 |
< |
assertSame(t, expected); |
146 |
> |
assertSame(expected.getClass(), t.getClass()); |
147 |
|
} |
148 |
|
|
149 |
|
try { |
150 |
|
a.get(); |
151 |
|
shouldThrow(); |
152 |
|
} catch (ExecutionException success) { |
153 |
< |
assertSame(t, success.getCause()); |
153 |
> |
assertSame(t.getClass(), success.getCause().getClass()); |
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()); |
160 |
> |
assertSame(t.getClass(), success.getCause().getClass()); |
161 |
|
} catch (Throwable fail) { threadUnexpectedException(fail); } |
162 |
|
} |
163 |
|
|
164 |
< |
static final class FJException extends RuntimeException { |
165 |
< |
FJException() { super(); } |
164 |
> |
public static final class FJException extends RuntimeException { |
165 |
> |
public FJException() { super(); } |
166 |
> |
public FJException(Throwable cause) { super(cause); } |
167 |
|
} |
168 |
|
|
169 |
|
// A simple recursive action for testing |
490 |
|
testInvokeOnPool(mainPool(), a); |
491 |
|
} |
492 |
|
|
492 |
– |
|
493 |
|
/** |
494 |
|
* helpQuiesce returns when tasks are complete. |
495 |
|
* getQueuedTaskCount returns 0 when quiescent |
499 |
|
public void realCompute() { |
500 |
|
FibAction f = new FibAction(8); |
501 |
|
assertSame(f, f.fork()); |
502 |
< |
f.helpQuiesce(); |
502 |
> |
helpQuiesce(); |
503 |
|
assertEquals(21, f.result); |
504 |
|
assertEquals(0, getQueuedTaskCount()); |
505 |
|
checkCompletedNormally(f); |
507 |
|
testInvokeOnPool(mainPool(), a); |
508 |
|
} |
509 |
|
|
510 |
– |
|
510 |
|
/** |
511 |
|
* invoke task throws exception when task completes abnormally |
512 |
|
*/ |
770 |
|
ForkJoinWorkerThread w = |
771 |
|
(ForkJoinWorkerThread) Thread.currentThread(); |
772 |
|
assertTrue(w.getPoolIndex() >= 0); |
773 |
< |
assertTrue(w.getPoolIndex() < mainPool.getPoolSize()); |
773 |
> |
// pool size can shrink after assigning index, so cannot check |
774 |
> |
// assertTrue(w.getPoolIndex() < mainPool.getPoolSize()); |
775 |
|
}}; |
776 |
|
testInvokeOnPool(mainPool, a); |
777 |
|
} |
778 |
|
|
779 |
– |
|
779 |
|
/** |
780 |
|
* setRawResult(null) succeeds |
781 |
|
*/ |
922 |
|
testInvokeOnPool(mainPool(), a); |
923 |
|
} |
924 |
|
|
926 |
– |
|
925 |
|
/** |
926 |
|
* invokeAll(tasks) with any null task throws NPE |
927 |
|
*/ |