128 |
|
private static final long profileThreshold = |
129 |
|
Long.getLong("jsr166.profileThreshold", 100); |
130 |
|
|
131 |
+ |
/** |
132 |
+ |
* The number of repetitions per test (for tickling rare bugs). |
133 |
+ |
*/ |
134 |
+ |
private static final int runsPerTest = |
135 |
+ |
Integer.getInteger("jsr166.runsPerTest", 1); |
136 |
+ |
|
137 |
|
protected void runTest() throws Throwable { |
138 |
< |
if (profileTests) |
139 |
< |
runTestProfiled(); |
140 |
< |
else |
141 |
< |
super.runTest(); |
138 |
> |
for (int i = 0; i < runsPerTest; i++) { |
139 |
> |
if (profileTests) |
140 |
> |
runTestProfiled(); |
141 |
> |
else |
142 |
> |
super.runTest(); |
143 |
> |
} |
144 |
|
} |
145 |
|
|
146 |
|
protected void runTestProfiled() throws Throwable { |
294 |
|
// Java8+ test classes |
295 |
|
if (atLeastJava8()) { |
296 |
|
String[] java8TestClassNames = { |
297 |
< |
"StampedLockTest", |
297 |
> |
"CompletableFutureTest", |
298 |
> |
"ConcurrentHashMap8Test", |
299 |
> |
"CountedCompleterTest", |
300 |
> |
"DoubleAccumulatorTest", |
301 |
> |
"DoubleAdderTest", |
302 |
|
"ForkJoinPool8Test", |
303 |
+ |
"LongAccumulatorTest", |
304 |
+ |
"LongAdderTest", |
305 |
+ |
"StampedLockTest", |
306 |
|
}; |
307 |
|
addNamedTestClasses(suite, java8TestClassNames); |
308 |
|
} |
1356 |
|
return null; |
1357 |
|
} |
1358 |
|
} |
1359 |
+ |
|
1360 |
+ |
public void assertThrows(Class<? extends Throwable> expectedExceptionClass, |
1361 |
+ |
Runnable... throwingActions) { |
1362 |
+ |
for (Runnable throwingAction : throwingActions) { |
1363 |
+ |
boolean threw = false; |
1364 |
+ |
try { throwingAction.run(); } |
1365 |
+ |
catch (Throwable t) { |
1366 |
+ |
threw = true; |
1367 |
+ |
if (!expectedExceptionClass.isInstance(t)) { |
1368 |
+ |
AssertionFailedError afe = |
1369 |
+ |
new AssertionFailedError |
1370 |
+ |
("Expected " + expectedExceptionClass.getName() + |
1371 |
+ |
", got " + t.getClass().getName()); |
1372 |
+ |
afe.initCause(t); |
1373 |
+ |
threadUnexpectedException(afe); |
1374 |
+ |
} |
1375 |
+ |
} |
1376 |
+ |
if (!threw) |
1377 |
+ |
shouldThrow(expectedExceptionClass.getName()); |
1378 |
+ |
} |
1379 |
+ |
} |
1380 |
|
} |