Package io.mats3.test

Class MatsTestHelp

java.lang.Object
io.mats3.test.MatsTestHelp

public class MatsTestHelp extends Object
Microscopic helper methods to create Loggers and Ids typically needed when making Mats tests.
  • Constructor Details

    • MatsTestHelp

      public MatsTestHelp()
  • Method Details

    • getClassLogger

      public static org.slf4j.Logger getClassLogger()
      Returns:
      a SLF4J Logger with the classname of the calling class (using Thread.currentThread().getStackTrace() to figure this out).
    • endpoint

      public static String endpoint()
      Returns:
      a String "{CallerClassSimpleName.method}.Endpoint".
    • endpoint

      public static String endpoint(String what)
      Returns:
      a String "{CallerClassSimpleName.method}.Endpoint.{what}".
    • terminator

      public static String terminator()
      Returns:
      a String "{CallerClassSimpleName.method}.Terminator".
    • terminator

      public static String terminator(String what)
      Returns:
      a String "{CallerClassSimpleName.method}.Terminator".
    • traceId

      public static String traceId()
      Returns:
      a String "{CallerClassSimpleName.method}.traceId.{randomId}" - BUT PLEASE NOTE!! ALWAYS use a semantically meaningful, globally unique Id as traceId in production code!
    • from

      public static String from()
      Returns:
      a String "{CallerClassSimpleName.method}".
    • from

      public static String from(String what)
      Returns:
      a String "{CallerClassSimpleName.method}.{what}".
    • randomId

      public static String randomId()
      Returns:
      a random string of length 8 for testing.
    • takeNap

      public static void takeNap(int millis) throws AssertionError
      Sleeps the specified number of milliseconds - can emulate processing time, primarily meant for the concurrency tests.
      Parameters:
      millis - the number of millis to sleep
      Throws:
      AssertionError - if an InterruptedException occurs.