Package herddb.utils
Class TestUtils
- java.lang.Object
-
- herddb.utils.TestUtils
-
public class TestUtils extends Object
- Author:
- francesco.caliumi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTestUtils.ThrowingRunnable** Copied from JUnit 4.13 ** *
-
Constructor Summary
Constructors Constructor Description TestUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertExceptionPresentInChain(Throwable t, Class<?> clazz)static voidassertThrows(Class<? extends Throwable> expectedThrowable, TestUtils.ThrowingRunnable runnable)Asserts thatrunnablethrows an exception of typeexpectedThrowablewhen executed.static <T extends Throwable>
TexpectThrows(Class<T> expectedThrowable, TestUtils.ThrowingRunnable runnable)Asserts thatrunnablethrows an exception of typeexpectedThrowablewhen executed.static <T extends Throwable>
TgetExceptionIfPresentInChain(Throwable t, Class<T> clazz)static booleanisExceptionPresentInChain(Throwable t, Class clazz)static <T extends Throwable>
voidverifyThrows(Class<T> expectedThrowable, TestUtils.ThrowingRunnable runnable, Function<T,Boolean> verify)static voidwaitForCondition(Callable<Boolean> condition, Callable<Void> callback, int seconds)static voidwaitForCondition(Callable<Boolean> condition, Callable<Void> callback, int seconds, String description)
-
-
-
Method Detail
-
assertThrows
public static void assertThrows(Class<? extends Throwable> expectedThrowable, TestUtils.ThrowingRunnable runnable)
Asserts thatrunnablethrows an exception of typeexpectedThrowablewhen executed. If it does not throw an exception, anAssertionErroris thrown. If it throws the wrong type of exception, anAssertionErroris thrown describing the mismatch; the exception that was actually thrown can be obtained by callingThrowable.getCause().- Parameters:
expectedThrowable- the expected type of the exceptionrunnable- a function that is expected to throw an exception when executed- Since:
- 4.13
-
expectThrows
public static <T extends Throwable> T expectThrows(Class<T> expectedThrowable, TestUtils.ThrowingRunnable runnable)
Asserts thatrunnablethrows an exception of typeexpectedThrowablewhen executed. If it does, the exception object is returned. If it does not throw an exception, anAssertionErroris thrown. If it throws the wrong type of exception, anAssertionErroris thrown describing the mismatch; the exception that was actually thrown can be obtained by callingThrowable.getCause().- Parameters:
expectedThrowable- the expected type of the exceptionrunnable- a function that is expected to throw an exception when executed- Returns:
- the exception thrown by
runnable - Since:
- 4.13
-
verifyThrows
public static <T extends Throwable> void verifyThrows(Class<T> expectedThrowable, TestUtils.ThrowingRunnable runnable, Function<T,Boolean> verify) throws Exception
- Throws:
Exception
-
waitForCondition
public static void waitForCondition(Callable<Boolean> condition, Callable<Void> callback, int seconds) throws Exception
- Throws:
Exception
-
waitForCondition
public static void waitForCondition(Callable<Boolean> condition, Callable<Void> callback, int seconds, String description) throws Exception
- Throws:
Exception
-
assertExceptionPresentInChain
public static void assertExceptionPresentInChain(Throwable t, Class<?> clazz)
-
isExceptionPresentInChain
public static boolean isExceptionPresentInChain(Throwable t, Class clazz)
-
-