Class LoggerStringWriter


  • public final class LoggerStringWriter
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String accumulated()
      Get the accumulated content that has been logged.
      static void assertContainsMdcPair​(java.lang.String value, java.lang.String expectedLabel, java.lang.String expectedValue)
      Verify that an MDC expectedLabel=expectedValue pair is present in value.
      static void remove()
      Remove the underlying in-memory log appender.
      static void reset()
      Clear the content of the accumulated().
      static java.lang.String stableAccumulated​(int totalWaitTimeMillis)
      Wait for the accumulated() content to remain unchanged for delayMillis milliseconds.
      static java.lang.String stableAccumulated​(int totalWaitTimeMillis, long sleepDurationMs)
      Wait for the accumulated() content to remain unchanged for sleepDurationMs milliseconds.
      • Methods inherited from class java.lang.Object

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

      • reset

        public static void reset()
        Clear the content of the accumulated().
      • remove

        public static void remove()
        Remove the underlying in-memory log appender.
      • accumulated

        public static java.lang.String accumulated()
        Get the accumulated content that has been logged.
        Returns:
        the accumulated content that has been logged.
      • stableAccumulated

        public static java.lang.String stableAccumulated​(int totalWaitTimeMillis)
                                                  throws java.lang.InterruptedException,
                                                         java.util.concurrent.TimeoutException
        Wait for the accumulated() content to remain unchanged for delayMillis milliseconds.
        Parameters:
        totalWaitTimeMillis - The amount of milliseconds to wait for the accumulated() content to stabilize.
        Returns:
        The accumulated content that has been logged.
        Throws:
        java.lang.InterruptedException - If interrupted while waiting for log content to stabilize.
        java.util.concurrent.TimeoutException - If the totalWaitTimeMillis duration has been exceeded and the accumulated() has not yet stabilize.
      • stableAccumulated

        public static java.lang.String stableAccumulated​(int totalWaitTimeMillis,
                                                         long sleepDurationMs)
                                                  throws java.lang.InterruptedException,
                                                         java.util.concurrent.TimeoutException
        Wait for the accumulated() content to remain unchanged for sleepDurationMs milliseconds.
        Parameters:
        totalWaitTimeMillis - The total amount of milliseconds to wait.
        sleepDurationMs - The amount of milliseconds to wait between checking if accumulated() has stabilize.
        Returns:
        The accumulated content that has been logged.
        Throws:
        java.lang.InterruptedException - If interrupted while waiting for log content to stabilize.
        java.util.concurrent.TimeoutException - If the totalWaitTimeMillis duration has been exceeded and the accumulated() has not yet stabilize.
      • assertContainsMdcPair

        public static void assertContainsMdcPair​(java.lang.String value,
                                                 java.lang.String expectedLabel,
                                                 java.lang.String expectedValue)
        Verify that an MDC expectedLabel=expectedValue pair is present in value.
        Parameters:
        value - The log line.
        expectedLabel - The MDC key.
        expectedValue - The MDC value.