--- jsr166/src/test/tck/JSR166TestCase.java 2013/02/06 16:57:21 1.101 +++ jsr166/src/test/tck/JSR166TestCase.java 2013/06/03 18:20:05 1.108 @@ -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 { @@ -286,8 +294,15 @@ public class JSR166TestCase extends Test // Java8+ test classes if (atLeastJava8()) { String[] java8TestClassNames = { - "StampedLockTest", + "CompletableFutureTest", + "ConcurrentHashMap8Test", + "CountedCompleterTest", + "DoubleAccumulatorTest", + "DoubleAdderTest", "ForkJoinPool8Test", + "LongAccumulatorTest", + "LongAdderTest", + "StampedLockTest", }; addNamedTestClasses(suite, java8TestClassNames); } @@ -1225,7 +1240,7 @@ public class JSR166TestCase extends Test public abstract class CheckedRecursiveAction extends RecursiveAction { protected abstract void realCompute() throws Throwable; - public final void compute() { + @Override protected final void compute() { try { realCompute(); } catch (Throwable t) { @@ -1240,7 +1255,7 @@ public class JSR166TestCase extends Test public abstract class CheckedRecursiveTask extends RecursiveTask { protected abstract T realCompute() throws Throwable; - public final T compute() { + @Override protected final T compute() { try { return realCompute(); } catch (Throwable t) { @@ -1341,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()); + } + } }