java.lang.Object
ee.jakarta.tck.concurrent.framework.junit.extensions.Wait

public final class Wait extends Object
Utility class for waiting for results. Prioritize polling for results, and discourages sleeping
  • Method Details

    • waitForTaskComplete

      public static <T> T waitForTaskComplete(Future<T> future)
      Waits for task to complete, but will timeout after TestConstants.waitTimeout
      Parameters:
      future - to wait for
      Returns:
      result
    • waitForTaskComplete

      public static <T> T waitForTaskComplete(Future<T> future, Duration timeout)
      Waits for task to complete, but will timeout after specified timeout
      Parameters:
      future - - the future to wait for
      timeout - - the duration of timeout
      Returns:
      result - result returned from future, or null if timeout was exceeded
    • waitForListenerComplete

      public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener)
      Wait for listener to complete, but will timeout after TestConstants.waitTimeout, and will be polled ever TestConstants.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 polled
      maxWaitTimeMillis - - timeout
      pollIntervalMillis - - 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 after TestConstants.waitTimeout, and will be polled every TestConstants.pollInterval
      Parameters:
      future - - the future to wait for
    • waitCancelFuture

      public static void waitCancelFuture(Future<?> future)
      Calls future.cancel(true), and then waits for future.done() to return true, but will timeout after TestConstants.waitTimeout, and will be polled every TestConstants.pollInterval
      Parameters:
      future - - the future to wait for
    • waitTillThreadFinish

      public static void waitTillThreadFinish(Thread thread)
      Waits until thread is finished, but will timeout after TestConstants.waitTimeout, and will be polled every TestConstants.pollInterval
      Parameters:
      thread - - the thread to wait for
    • waitForTransactionBegan

      public static void waitForTransactionBegan(CancelledTransactedTask task)
      Waits for task to report the transaction has begun, but will timeout after TestConstants.waitTimeout, and will be polled every TestConstants.pollInterval
      Parameters:
      task - - the task to wait for
    • waitForCounter

      public static void waitForCounter(IntSupplier counter, int expected)
      Waits for a counter to report an expected value, but will timeout after TestConstants.waitTimeout, and will be polled every TestConstants.pollInterval
      Parameters:
      counter -
      expected -
    • sleep

      public static void sleep(Duration time)