ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/JSR166TestCase.java
(Generate patch)

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.104 by dl, Thu Mar 21 00:26:43 2013 UTC vs.
Revision 1.110 by jsr166, Sun Jul 14 22:39:31 2013 UTC

# Line 128 | Line 128 | public class JSR166TestCase extends Test
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 {
# Line 287 | Line 295 | public class JSR166TestCase extends Test
295          if (atLeastJava8()) {
296              String[] java8TestClassNames = {
297                  "CompletableFutureTest",
298 +                "ConcurrentHashMap8Test",
299                  "CountedCompleterTest",
300                  "DoubleAccumulatorTest",
301                  "DoubleAdderTest",
302                  "ForkJoinPool8Test",
303                  "LongAccumulatorTest",
304                  "LongAdderTest",
305 +                "SplittableRandomTest",
306                  "StampedLockTest",
307              };
308              addNamedTestClasses(suite, java8TestClassNames);
# Line 301 | Line 311 | public class JSR166TestCase extends Test
311          return suite;
312      }
313  
314 +    // Delays for timing-dependent tests, in milliseconds.
315  
316      public static long SHORT_DELAY_MS;
317      public static long SMALL_DELAY_MS;
318      public static long MEDIUM_DELAY_MS;
319      public static long LONG_DELAY_MS;
320  
310
321      /**
322       * Returns the shortest timed delay. This could
323       * be reimplemented to use for example a Property.
# Line 700 | Line 710 | public class JSR166TestCase extends Test
710      public static final Integer m6  = new Integer(-6);
711      public static final Integer m10 = new Integer(-10);
712  
703
713      /**
714       * Runs Runnable r with a security policy that permits precisely
715       * the specified permissions.  If there is no current security
# Line 1231 | Line 1240 | public class JSR166TestCase extends Test
1240      public abstract class CheckedRecursiveAction extends RecursiveAction {
1241          protected abstract void realCompute() throws Throwable;
1242  
1243 <        public final void compute() {
1243 >        @Override protected final void compute() {
1244              try {
1245                  realCompute();
1246              } catch (Throwable t) {
# Line 1246 | Line 1255 | public class JSR166TestCase extends Test
1255      public abstract class CheckedRecursiveTask<T> extends RecursiveTask<T> {
1256          protected abstract T realCompute() throws Throwable;
1257  
1258 <        public final T compute() {
1258 >        @Override protected final T compute() {
1259              try {
1260                  return realCompute();
1261              } catch (Throwable t) {
# Line 1347 | Line 1356 | public class JSR166TestCase extends Test
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines