|
|
@@ -45,18 +45,18 @@ public final class NewAssert extends org.junit.Assert {
|
|
|
public static void assertThrows(Class<? extends Throwable> error, Action action) {
|
|
|
try {
|
|
|
action.run();
|
|
|
- fail(error + " expected");
|
|
|
} catch(Throwable cause) { // NOPMD
|
|
|
- if( !error.isInstance(cause)) {
|
|
|
+ if( error.isInstance(cause)) {
|
|
|
throw TestUtils.rethrow(cause);
|
|
|
}
|
|
|
+ return;
|
|
|
}
|
|
|
+ fail(error + " expected");
|
|
|
}
|
|
|
|
|
|
public static void assertThrows(Class<? extends Throwable> error, Class<? extends Throwable> cause, Action action) {
|
|
|
try {
|
|
|
action.run();
|
|
|
- fail(error + " expected");
|
|
|
} catch(Throwable e) { // NOPMD
|
|
|
if( !error.isInstance(e)) {
|
|
|
throw TestUtils.rethrow(e);
|
|
|
@@ -65,13 +65,14 @@ public final class NewAssert extends org.junit.Assert {
|
|
|
if( !cause.isInstance(c)) {
|
|
|
throw TestUtils.rethrow(e);
|
|
|
}
|
|
|
+ return;
|
|
|
}
|
|
|
+ fail(error + " expected");
|
|
|
}
|
|
|
|
|
|
public static void assertThrows(Class<? extends Throwable> error, String message, Action action) {
|
|
|
try {
|
|
|
action.run();
|
|
|
- fail(error + " expected");
|
|
|
} catch(Throwable cause) { // NOPMD
|
|
|
if( !error.isInstance(cause)) {
|
|
|
throw TestUtils.rethrow(cause);
|
|
|
@@ -79,18 +80,21 @@ public final class NewAssert extends org.junit.Assert {
|
|
|
if( !message.equals(cause.getMessage())) {
|
|
|
throw TestUtils.rethrow(cause);
|
|
|
}
|
|
|
+ return;
|
|
|
}
|
|
|
+ fail(error + " expected");
|
|
|
}
|
|
|
|
|
|
public static void assertThrows(Predicate<Throwable> handler, Action action) {
|
|
|
try {
|
|
|
action.run();
|
|
|
- fail("Exception expected");
|
|
|
} catch(Throwable cause) { // NOPMD
|
|
|
if( !handler.test(cause)) {
|
|
|
throw TestUtils.rethrow(cause);
|
|
|
}
|
|
|
+ return;
|
|
|
}
|
|
|
+ fail("Exception expected");
|
|
|
}
|
|
|
|
|
|
public static void assertSerializable(Object value) {
|