Class BlockingTestUtility


  • public final class BlockingTestUtility
    extends Object
    Utility class to test code that enters a blocking condition.
    See Also:
    IBlockingCondition.waitFor(String...), IBlockingCondition.waitFor(long, TimeUnit, String...)
    • Method Detail

      • runBlockingAction

        public static void runBlockingAction​(org.eclipse.scout.rt.platform.util.concurrent.IRunnable runnableGettingBlocked,
                                             org.eclipse.scout.rt.platform.util.concurrent.IRunnable runnableOnceBlocked)
        Helper method to test code which will enter a blocking condition.

        calls runBlockingAction(IRunnable, IRunnable, boolean) with awaitBackgroundJobs=false

      • runBlockingAction

        public static void runBlockingAction​(org.eclipse.scout.rt.platform.util.concurrent.IRunnable runnableGettingBlocked,
                                             org.eclipse.scout.rt.platform.util.concurrent.IRunnable runnableOnceBlocked,
                                             boolean awaitBackgroundJobs)
        Helper method to test code which will enter a blocking condition.

        If runnableOnceBlocked throws an exception, it is given to JUnitExceptionHandler to make the JUnit test fail.

        Parameters:
        runnableGettingBlocked - IRunnable that will enter a blocking condition.
        runnableOnceBlocked - IRunnable to be executed once the 'runnableGettingBlocked' enters a blocking condition.
        awaitBackgroundJobs - true waits for background jobs running in the same session to complete before runnableOnceBlocked is called
      • addBlockingConditionTimeoutListener

        public static BlockingTestUtility.IBlockingConditionTimeoutHandle addBlockingConditionTimeoutListener​(long timeout,
                                                                                                              TimeUnit unit)
        Used by ClientTestRunner to detect unexpected blocking conditions (forms)

        Adds a blocking condition timeout listener on IJobManager for the current IClientSession

        Returns:
        the handle for the listener containing the first exception caught. Call IRegistrationHandle.dispose() to remove the listener.
      • runBlockingActionWithMessageBoxDefaultResult

        public static void runBlockingActionWithMessageBoxDefaultResult​(org.eclipse.scout.rt.platform.util.concurrent.IRunnable runnable,
                                                                        int messageBoxResult)
        Runs an action that will be blocked by a message box. All message boxes appearing during the execution of the action are answered by the specified option.

        If you need a distinguish multiple message boxes and give different answers, use runBlockingActionWithMessageBoxHandler(IRunnable, ToIntFunction) instead.

        Parameters:
        runnable - The action to be executed that will cause the message box to appear
        messageBoxResult - The return value for the message box. See IMessageBox for possible values.
      • runBlockingActionWithMessageBoxHandler

        public static void runBlockingActionWithMessageBoxHandler​(org.eclipse.scout.rt.platform.util.concurrent.IRunnable runnable,
                                                                  ToIntFunction<IMessageBox> messageBoxHandler)
        Runs an action that will be blocked by a message box. For each message box, the handling function is called to determine the return value.

        If you need don't need to different return values for different message boxes, you can use runBlockingActionWithMessageBoxDefaultResult(IRunnable, int) instead. See IMessageBox for possible values.

        Parameters:
        runnable - The action to be executed that will cause the message box to appear
        messageBoxHandler - The handling function that will be used to determine the return value in the message box.