public final class ExceptionHelper extends Object
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
LOGGER
The
Logger instance. |
Modifier | Constructor and Description |
---|---|
private |
ExceptionHelper()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
static <T extends Throwable> |
assertCause(Throwable catched,
Class<T> expectedType)
This method should be invoked in catch-block of tests that catched a given exception and expect that this exception
or one of its
causes are an instance of the given
expectedType . |
static void |
assertCause(Throwable catched,
Throwable expectedCause)
This method should be invoked in catch-block of tests that catched a given exception and expect that this exception
or one of its
causes is the same as the given expectedCause . |
static void |
failExceptionExpected()
This method should be invoked in try-blocks of tests that expect an exception to be thrown.
|
static <T extends Throwable> |
getCause(Throwable catched,
Class<T> expectedType)
This method gets a catched exception or one of its
causes that is an
instance of the given expectedType . |
static boolean |
isCause(Throwable catched,
Class<? extends Throwable> expectedType)
This method checks if a catched exception or one of its
causes is an
instance of the given expectedType . |
static boolean |
isCause(Throwable catched,
Throwable expectedCause)
This method should be invoked in catch-block of tests that catched a given exception and expect that this exception
or one of its
causes is the same as the given expectedCause . |
public static void failExceptionExpected()
public static <T extends Throwable> T assertCause(Throwable catched, Class<T> expectedType)
causes
are an instance of
the given
expectedType
.public static boolean isCause(Throwable catched, Class<? extends Throwable> expectedType)
causes
is an
instance of
the given expectedType
.catched
- is the Throwable
that has been catched.expectedType
- is the Class
of the Throwable
that is expected.true
if the given catched
or one of its causes
is an
instance of
the given expectedType
.public static <T extends Throwable> T getCause(Throwable catched, Class<T> expectedType)
causes
that is an
instance of
the given expectedType
.T
- is the generic type of the expected cause.catched
- is the Throwable
that has been catched.expectedType
- is the Class
of the Throwable
that is expected.true
if the given catched
or one of its causes
is an
instance of
the given expectedType
.public static void assertCause(Throwable catched, Throwable expectedCause)
causes
is the same as the given expectedCause
.Copyright © 2001–2016 mmm-Team. All rights reserved.