Class AbstractLoggerJUnit

  • Direct Known Subclasses:
    LoggerExtension, LoggerRule

    public class AbstractLoggerJUnit
    extends java.util.logging.Handler
    Abstract JUnit Logger functionality.
    Author:
    Daniel Sagenschneider
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.logging.LogRecord[] assertLog​(java.lang.String message)
      Asserts a LogRecord at any Level by any Logger.
      java.util.logging.LogRecord[] assertLog​(java.lang.String loggerName, java.util.logging.Level level, java.lang.String message)
      Asserts a specific LogRecord.
      java.util.logging.LogRecord[] assertLog​(java.util.logging.Level level, java.lang.String message)
      Asserts a LogRecord at particular Level by any Logger.
      void clear()
      Clears the logs.
      void close()  
      void flush()  
      void publish​(java.util.logging.LogRecord record)  
      protected void setupLogCapture()
      Sets up the log capture.
      protected void teardownLogCapture()
      Tears down the log capture.
      • Methods inherited from class java.util.logging.Handler

        getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractLoggerJUnit

        public AbstractLoggerJUnit()
    • Method Detail

      • assertLog

        public java.util.logging.LogRecord[] assertLog​(java.lang.String message)
        Asserts a LogRecord at any Level by any Logger.
        Parameters:
        message - Message for Logger.
        Returns:
        Matching LogRecord instances.
      • assertLog

        public java.util.logging.LogRecord[] assertLog​(java.util.logging.Level level,
                                                       java.lang.String message)
        Asserts a LogRecord at particular Level by any Logger.
        Parameters:
        level - Expected Level.
        message - Expected message.
        Returns:
        Matching LogRecord instances.
      • assertLog

        public java.util.logging.LogRecord[] assertLog​(java.lang.String loggerName,
                                                       java.util.logging.Level level,
                                                       java.lang.String message)
        Asserts a specific LogRecord.
        Parameters:
        loggerName - Name of Logger.
        level - Expected Level.
        message - Expected message.
        Returns:
        Matching LogRecord instances.
      • clear

        public void clear()
        Clears the logs.
      • setupLogCapture

        protected void setupLogCapture()
        Sets up the log capture.
      • teardownLogCapture

        protected void teardownLogCapture()
        Tears down the log capture.
      • publish

        public void publish​(java.util.logging.LogRecord record)
        Specified by:
        publish in class java.util.logging.Handler
      • flush

        public void flush()
        Specified by:
        flush in class java.util.logging.Handler
      • close

        public void close()
                   throws java.lang.SecurityException
        Specified by:
        close in class java.util.logging.Handler
        Throws:
        java.lang.SecurityException