- java.lang.Object
-
- org.junit.jupiter.api.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AssertTimeoutPreemptively.ExecutionTimeoutException
private static class
AssertTimeoutPreemptively.TimeoutThreadFactory
The thread factory used for preemptive timeout.
-
Constructor Summary
Constructors Constructor Description AssertTimeoutPreemptively()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static void
assertTimeoutPreemptively(java.time.Duration timeout, Executable executable)
(package private) static void
assertTimeoutPreemptively(java.time.Duration timeout, Executable executable, java.lang.String message)
(package private) static void
assertTimeoutPreemptively(java.time.Duration timeout, Executable executable, java.util.function.Supplier<java.lang.String> messageSupplier)
(package private) static <T> T
assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier)
(package private) static <T> T
assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.lang.String message)
(package private) static <T> T
assertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.util.function.Supplier<java.lang.String> messageSupplier)
(package private) static <T,E extends java.lang.Throwable>
TassertTimeoutPreemptively(java.time.Duration timeout, ThrowingSupplier<T> supplier, java.util.function.Supplier<java.lang.String> messageSupplier, Assertions.TimeoutFailureFactory<E> failureFactory)
private static org.opentest4j.AssertionFailedError
createAssertionFailure(java.time.Duration timeout, java.util.function.Supplier<java.lang.String> messageSupplier, java.lang.Throwable cause)
private static <T,E extends java.lang.Throwable>
TresolveFutureAndHandleException(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)
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)
-
-
-
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)
-
-