Class SystemStreamUtil

java.lang.Object
org.javalite.test.SystemStreamUtil

public class SystemStreamUtil extends Object
This class can be used to catch standard and error outputs in tests so as not to pollute test printout with "good" exceptions stack traces.
Author:
Igor Polevoy: 3/5/12 12:25 PM
  • Method Details

    • replaceOut

      public static void replaceOut()
      Replaces System.out with internal buffer. All calls such as System.out.print... will go to this buffer and not to STDIO
    • getSystemOut

      public static String getSystemOut()
      Returns buffer accumulated with data as string.
      Returns:
      buffer accumulated with data as string.
    • restoreSystemOut

      public static void restoreSystemOut()
      Restores System.out to former glory.
    • replaceError

      public static void replaceError()
      Replaces System.err with internal buffer. All calls such as System.err.print... will go to this buffer and not to STDERR
    • getSystemErr

      public static String getSystemErr()
      Returns buffer accumulated with data as string.
      Returns:
      buffer accumulated with data as string.
    • restoreSystemErr

      public static void restoreSystemErr()
      Restores System.err to former glory.