Class LogAsserts

java.lang.Object
de.cuioss.test.juli.LogAsserts

public class LogAsserts extends Object
Provides a number of asserts against the LogRecords gathered by TestLogHandler. Caution: In order to use the asserts the TestLogHandler must be properly configured by calling TestLoggerFactory.install() prior to usage. Usually this is done by EnableTestLogger
Author:
Oliver Wolff
  • Constructor Details

  • Method Details

    • assertLogMessagePresent

      public static void assertLogMessagePresent(TestLogLevel logLevel, String message)
      Asserts whether at least one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      message - to be checked, must not be null
    • assertNoLogMessagePresent

      public static void assertNoLogMessagePresent(TestLogLevel logLevel, String messagePart)
      Asserts whether no LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      messagePart - to be checked, must not be null
    • assertNoLogMessagePresent

      public static void assertNoLogMessagePresent(TestLogLevel logLevel, Class<?> logger)
      Asserts whether no LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      logger - to be checked, must not be null
    • assertSingleLogMessagePresent

      public static void assertSingleLogMessagePresent(TestLogLevel logLevel, String message)
      Asserts whether exactly one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      message - to be checked, must not be null
    • assertLogMessagePresent

      public static void assertLogMessagePresent(TestLogLevel logLevel, String message, Throwable throwable)
      Asserts whether at least one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      message - to be checked, must not be null
      throwable - to be checked, must not be null
    • assertSingleLogMessagePresent

      public static void assertSingleLogMessagePresent(TestLogLevel logLevel, String message, Throwable throwable)
      Asserts whether exactly one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      message - to be checked, must not be null
      throwable - to be checked, must not be null
    • assertLogMessagePresent

      public static void assertLogMessagePresent(TestLogLevel logLevel, String message, Class<? extends Throwable> throwableClass)
      Asserts whether at least one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      message - to be checked, must not be null
      throwableClass - to be checked, must not be null
    • assertSingleLogMessagePresent

      public static void assertSingleLogMessagePresent(TestLogLevel logLevel, String message, Class<? extends Throwable> throwableClass)
      Asserts whether exactly one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      message - to be checked, must not be null
      throwableClass - to be checked, must not be null
    • assertLogMessagePresentContaining

      public static void assertLogMessagePresentContaining(TestLogLevel logLevel, String messagePart)
      Asserts whether at least one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      messagePart - to be checked, must not be null
    • assertSingleLogMessagePresentContaining

      public static void assertSingleLogMessagePresentContaining(TestLogLevel logLevel, String messagePart)
      Asserts whether exactly one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      messagePart - to be checked, must not be null
    • assertLogMessagePresentContaining

      public static void assertLogMessagePresentContaining(TestLogLevel logLevel, String messagePart, Throwable throwable)
      Asserts whether at least one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      messagePart - to be checked, must not be null
      throwable - to be checked, must not be null
    • assertLogMessagePresentContaining

      public static void assertLogMessagePresentContaining(TestLogLevel logLevel, String messagePart, Class<? extends Throwable> throwableClass)
      Asserts whether at least one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      messagePart - to be checked, must not be null
      throwableClass - to be checked, must not be null
    • assertSingleLogMessagePresentContaining

      public static void assertSingleLogMessagePresentContaining(TestLogLevel logLevel, String messagePart, Throwable throwable)
      Asserts whether exactly one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      messagePart - to be checked, must not be null
      throwable - to be checked, must not be null
    • assertSingleLogMessagePresentContaining

      public static void assertSingleLogMessagePresentContaining(TestLogLevel logLevel, String messagePart, Class<? extends Throwable> throwableClass)
      Asserts whether exactly one LogRecord for the given parameter is present
      Parameters:
      logLevel - to be checked, must not be null
      messagePart - to be checked, must not be null
      throwableClass - to be checked, must not be null