Class Wait

java.lang.Object
org.javalite.common.Wait

public class Wait extends Object
Borrowed from Apache Artemis. Can wait for a condition.
Example of usage:

   Wait.waitFor(() -> messageService.getMessageCount() == 1);
 

Defaults:

  • MAX_WAIT_MILLIS = 30 * 1000
  • SLEEP_MILLIS = 100
    • Constructor Details

      • Wait

        public Wait()
    • Method Details

      • waitFor

        public static boolean waitFor(Wait.Condition condition)
        Parameters:
        condition - condition to check from time to time;
        Returns:
        true if condition was satisfied, false if not.
      • waitFor

        public static boolean waitFor(long durationMillis, Wait.Condition condition)
        Waits for a condition to be satisfied or till durationMillis, whichever is sooner.
        Parameters:
        durationMillis - max time to wait in millis.
        condition - condition to check from time to time;
        Returns:
        true if condition was satisfied, false if not.
      • waitFor

        public static boolean waitFor(long durationMillis, long sleepMillis, Wait.Condition condition)
        Parameters:
        sleepMillis - time to sleep between checks.
        durationMillis - max time to wait in millis.
        condition - condition to check from time to time;
        Returns:
        true if condition was satisfied, false if not.