Class BlockHoundHelper

java.lang.Object
org.infinispan.commons.test.BlockHoundHelper

public class BlockHoundHelper extends Object
  • Method Details

    • currentThreadRequiresNonBlocking

      public static boolean currentThreadRequiresNonBlocking()
      Returns true if the current thread at this time requires all invocations to be non blocking
    • ensureNonBlocking

      public static <V> V ensureNonBlocking(Supplier<V> supplier)
      Invokes the provided Supplier in a scope that guarantees that the current thread is not blocked. If blocking is found the invoking test will fail.
    • ensureNonBlocking

      public static void ensureNonBlocking(Runnable runnable)
      Invokes the provided Runnable in a scope that guarantees that the current thread is not blocked. If blocking is found the invoking test will fail.
    • allowBlocking

      public static void allowBlocking(Runnable runnable)
    • ensureNonBlockingExecutor

      public static Executor ensureNonBlockingExecutor()
      Returns an Executor that when supplied a task, will guarantee that task does not block when invoked. If the task does block it will fail the invoking test.
    • allowBlockingExecutor

      public static Executor allowBlockingExecutor()
      Returns an Executor that when supplied a task, will allow it to invoke blocking calls, even if the invoking context was already registered as non blocking. Useful to mock submission to a blocking executor.
    • blockingConsume

      public static <V> void blockingConsume(V consumed)
      Helper method that "blocks" as dictated by block hound but in actuality does nothing. This is useful to detect if the given code is actually be invoked in an method that allows for blocking or not.
      Type Parameters:
      V - whatever desired type is
      Parameters:
      consumed - an argument useful for making this method a `Consumer` via method reference