Class AssertTimeoutPreemptively


  • class AssertTimeoutPreemptively
    extends java.lang.Object
    AssertTimeout is a collection of utility methods that support asserting the execution of the code under test did not take longer than the timeout duration using a preemptive approach.
    Since:
    5.9.1
    • Constructor Detail

      • AssertTimeoutPreemptively

        AssertTimeoutPreemptively()
    • Method Detail

      • assertTimeoutPreemptively

        static void assertTimeoutPreemptively​(java.time.Duration timeout,
                                              Executable executable)
      • assertTimeoutPreemptively

        static void assertTimeoutPreemptively​(java.time.Duration timeout,
                                              Executable executable,
                                              java.lang.String message)
      • assertTimeoutPreemptively

        static void assertTimeoutPreemptively​(java.time.Duration timeout,
                                              Executable executable,
                                              java.util.function.Supplier<java.lang.String> messageSupplier)
      • assertTimeoutPreemptively

        static <T> T assertTimeoutPreemptively​(java.time.Duration timeout,
                                               ThrowingSupplier<T> supplier)
      • assertTimeoutPreemptively

        static <T> T assertTimeoutPreemptively​(java.time.Duration timeout,
                                               ThrowingSupplier<T> supplier,
                                               java.lang.String message)
      • assertTimeoutPreemptively

        static <T> T assertTimeoutPreemptively​(java.time.Duration timeout,
                                               ThrowingSupplier<T> supplier,
                                               java.util.function.Supplier<java.lang.String> messageSupplier)
      • assertTimeoutPreemptively

        static <T,​E extends java.lang.Throwable> T assertTimeoutPreemptively​(java.time.Duration timeout,
                                                                                   ThrowingSupplier<T> supplier,
                                                                                   java.util.function.Supplier<java.lang.String> messageSupplier,
                                                                                   Assertions.TimeoutFailureFactory<E> failureFactory)
                                                                            throws E extends java.lang.Throwable
        Throws:
        E extends java.lang.Throwable
      • submitTask

        private static <T> java.util.concurrent.Future<T> submitTask​(ThrowingSupplier<T> supplier,
                                                                     java.util.concurrent.atomic.AtomicReference<java.lang.Thread> threadReference,
                                                                     java.util.concurrent.ExecutorService executorService)
      • resolveFutureAndHandleException

        private static <T,​E extends java.lang.Throwable> T resolveFutureAndHandleException​(java.util.concurrent.Future<T> future,
                                                                                                 java.time.Duration timeout,
                                                                                                 java.util.function.Supplier<java.lang.String> messageSupplier,
                                                                                                 java.util.function.Supplier<java.lang.Thread> threadSupplier,
                                                                                                 Assertions.TimeoutFailureFactory<E> failureFactory)
                                                                                          throws E extends java.lang.Throwable
        Throws:
        E extends java.lang.Throwable
      • createAssertionFailure

        private static org.opentest4j.AssertionFailedError createAssertionFailure​(java.time.Duration timeout,
                                                                                  java.util.function.Supplier<java.lang.String> messageSupplier,
                                                                                  java.lang.Throwable cause)