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.105 by dl, Thu Mar 21 19:06:54 2013 UTC vs.
Revision 1.106 by jsr166, Mon Apr 1 20:06:26 2013 UTC

# Line 1348 | Line 1348 | public class JSR166TestCase extends Test
1348              return null;
1349          }
1350      }
1351 +
1352 +    public void assertThrows(Class<? extends Throwable> expectedExceptionClass,
1353 +                             Runnable... throwingActions) {
1354 +        for (Runnable throwingAction : throwingActions) {
1355 +            boolean threw = false;
1356 +            try { throwingAction.run(); }
1357 +            catch (Throwable t) {
1358 +                threw = true;
1359 +                if (!expectedExceptionClass.isInstance(t)) {
1360 +                    AssertionFailedError afe =
1361 +                        new AssertionFailedError
1362 +                        ("Expected " + expectedExceptionClass.getName() +
1363 +                         ", got " + t.getClass().getName());
1364 +                    afe.initCause(t);
1365 +                    threadUnexpectedException(afe);
1366 +                }
1367 +            }
1368 +            if (!threw)
1369 +                shouldThrow(expectedExceptionClass.getName());
1370 +        }
1371 +    }
1372   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines