Package herddb.utils

Class TestUtils


  • public class TestUtils
    extends Object
    Author:
    francesco.caliumi
    • Constructor Detail

      • TestUtils

        public TestUtils()
    • Method Detail

      • assertThrows

        public static void assertThrows​(Class<? extends Throwable> expectedThrowable,
                                        TestUtils.ThrowingRunnable runnable)
        Asserts that runnable throws an exception of type expectedThrowable when executed. If it does not throw an exception, an AssertionError is thrown. If it throws the wrong type of exception, an AssertionError is thrown describing the mismatch; the exception that was actually thrown can be obtained by calling Throwable.getCause().
        Parameters:
        expectedThrowable - the expected type of the exception
        runnable - 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 that runnable throws an exception of type expectedThrowable when executed. If it does, the exception object is returned. If it does not throw an exception, an AssertionError is thrown. If it throws the wrong type of exception, an AssertionError is thrown describing the mismatch; the exception that was actually thrown can be obtained by calling Throwable.getCause().
        Parameters:
        expectedThrowable - the expected type of the exception
        runnable - a function that is expected to throw an exception when executed
        Returns:
        the exception thrown by runnable
        Since:
        4.13
      • assertExceptionPresentInChain

        public static void assertExceptionPresentInChain​(Throwable t,
                                                         Class<?> clazz)
      • isExceptionPresentInChain

        public static boolean isExceptionPresentInChain​(Throwable t,
                                                        Class clazz)
      • getExceptionIfPresentInChain

        public static <T extends Throwable> T getExceptionIfPresentInChain​(Throwable t,
                                                                           Class<T> clazz)