Class Wait
java.lang.Object
ee.jakarta.tck.concurrent.framework.junit.extensions.Wait
Utility class for waiting for results.
Prioritize polling for results, and discourages sleeping
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
waitCancelFuture
(Future<?> future) Calls future.cancel(true), and then waits for future.done() to return true, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
static void
waitForCounter
(IntSupplier counter, int expected) Waits for a counter to report an expected value, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
static void
waitForListenerComplete
(ManagedTaskListenerImpl managedTaskListener) Wait for listener to complete, but will timeout afterTestConstants.waitTimeout
, and will be polled everTestConstants.pollInterval
static void
waitForListenerComplete
(ManagedTaskListenerImpl managedTaskListener, Duration timeout, Duration pollInterval) Wait for listener to complete, but will timeout after a specified timeout, and will be polled ever specified intervalstatic <T> T
waitForTaskComplete
(Future<T> future) Waits for task to complete, but will timeout afterTestConstants.waitTimeout
static <T> T
waitForTaskComplete
(Future<T> future, Duration timeout) Waits for task to complete, but will timeout after specified timeoutstatic void
Waits for task to report the transaction has begun, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
static <T extends Throwable>
voidwaitTillFutureThrowsException
(Future<?> future, Class<T> expected) Waits for future to throw an error, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
static void
waitTillThreadFinish
(Thread thread) Waits until thread is finished, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
-
Method Details
-
waitForTaskComplete
Waits for task to complete, but will timeout afterTestConstants.waitTimeout
- Parameters:
future
- to wait for- Returns:
- result
-
waitForTaskComplete
Waits for task to complete, but will timeout after specified timeout- Parameters:
future
- - the future to wait fortimeout
- - the duration of timeout- Returns:
- result - result returned from future, or null if timeout was exceeded
-
waitForListenerComplete
Wait for listener to complete, but will timeout afterTestConstants.waitTimeout
, and will be polled everTestConstants.pollInterval
- Parameters:
managedTaskListener
- - the listener to be polled
-
waitForListenerComplete
public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener, Duration timeout, Duration pollInterval) Wait for listener to complete, but will timeout after a specified timeout, and will be polled ever specified interval- Parameters:
managedTaskListener
- - the listener to be polledmaxWaitTimeMillis
- - timeoutpollIntervalMillis
- - poll interval
-
waitTillFutureThrowsException
public static <T extends Throwable> void waitTillFutureThrowsException(Future<?> future, Class<T> expected) Waits for future to throw an error, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
- Parameters:
future
- - the future to wait for
-
waitCancelFuture
Calls future.cancel(true), and then waits for future.done() to return true, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
- Parameters:
future
- - the future to wait for
-
waitTillThreadFinish
Waits until thread is finished, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
- Parameters:
thread
- - the thread to wait for
-
waitForTransactionBegan
Waits for task to report the transaction has begun, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
- Parameters:
task
- - the task to wait for
-
waitForCounter
Waits for a counter to report an expected value, but will timeout afterTestConstants.waitTimeout
, and will be polled everyTestConstants.pollInterval
- Parameters:
counter
-expected
-
-
sleep
-