Class Synchroniser

  • All Implemented Interfaces:
    ThreadingPolicy

    public class Synchroniser
    extends java.lang.Object
    implements ThreadingPolicy
    A ThreadingPolicy that makes the Mockery thread-safe and helps tests synchronise with background threads.
    Author:
    Nat Pryce, olibye
    • Constructor Detail

      • Synchroniser

        public Synchroniser()
    • Method Detail

      • waitUntil

        public void waitUntil​(StatePredicate p)
                       throws java.lang.InterruptedException
        Waits for a StatePredicate to become active. Warning: this will wait forever unless the test itself has a timeout.
        Parameters:
        p - the StatePredicate to wait for
        Throws:
        java.lang.InterruptedException
      • waitUntil

        public void waitUntil​(StatePredicate p,
                              long timeoutMs)
                       throws java.lang.InterruptedException
        Waits up to a timeout for a StatePredicate to become active. Fails the test if the timeout expires.
        Parameters:
        p - the StatePredicate to wait for
        timeoutMs - the timeout in milliseconds
        Throws:
        java.lang.InterruptedException