--- jsr166/src/test/tck/JSR166TestCase.java 2013/03/21 00:26:43 1.104 +++ jsr166/src/test/tck/JSR166TestCase.java 2013/04/21 06:19:58 1.107 @@ -128,11 +128,19 @@ public class JSR166TestCase extends Test private static final long profileThreshold = Long.getLong("jsr166.profileThreshold", 100); + /** + * The number of repetitions per test (for tickling rare bugs). + */ + private static final int runsPerTest = + Integer.getInteger("jsr166.runsPerTest", 1); + protected void runTest() throws Throwable { - if (profileTests) - runTestProfiled(); - else - super.runTest(); + for (int i = 0; i < runsPerTest; i++) { + if (profileTests) + runTestProfiled(); + else + super.runTest(); + } } protected void runTestProfiled() throws Throwable { @@ -287,6 +295,7 @@ public class JSR166TestCase extends Test if (atLeastJava8()) { String[] java8TestClassNames = { "CompletableFutureTest", + "ConcurrentHashMap8Test", "CountedCompleterTest", "DoubleAccumulatorTest", "DoubleAdderTest", @@ -1347,4 +1356,25 @@ public class JSR166TestCase extends Test return null; } } + + public void assertThrows(Class expectedExceptionClass, + Runnable... throwingActions) { + for (Runnable throwingAction : throwingActions) { + boolean threw = false; + try { throwingAction.run(); } + catch (Throwable t) { + threw = true; + if (!expectedExceptionClass.isInstance(t)) { + AssertionFailedError afe = + new AssertionFailedError + ("Expected " + expectedExceptionClass.getName() + + ", got " + t.getClass().getName()); + afe.initCause(t); + threadUnexpectedException(afe); + } + } + if (!threw) + shouldThrow(expectedExceptionClass.getName()); + } + } }