SystemOutAndErrSwapper (Grails 6.0.0)

Package: org.grails.test.io

## [Groovy] Class SystemOutAndErrSwapper

- org.grails.test.io.SystemOutAndErrSwapper

-     @groovy.transform.CompileStatic
      class SystemOutAndErrSwapper
      extends java.lang.Object

  Convenience class to temporarily swap in an output stream for standard error and standard out.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `SystemOutAndErrSwapper.TestOutputCapturingPrintStream` |

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private boolean` | `echoErr` |
    `private boolean` | `echoOut` |
    `protected boolean` | `swapped` |
    `protected java.io.PrintStream` | `swappedInErr` |
    `protected java.io.OutputStream` | `swappedInErrStream` |
    `protected java.io.PrintStream` | `swappedInOut` |
    `protected java.io.OutputStream` | `swappedInOutStream` |
    `protected java.io.PrintStream` | `swappedOutErr` |
    `protected java.io.PrintStream` | `swappedOutOut` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `boolean` | `echoErr`
    `boolean` | `echoOut`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `SystemOutAndErrSwapper (boolean echoOut, boolean echoErr)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `boolean` | `isSwapped()`
    `` | `java.util.List<java.io.OutputStream>` | `swapIn()` Replaces System.out and System.err with PrintStream's wrapping outStream and errStream
    `` | `java.util.List<java.io.OutputStream>` | `swapIn(java.io.OutputStream outStream, java.io.OutputStream errStream)` Replaces System.out and System.err with PrintStream's wrapping outStream and errStream
    `` | `java.util.List<java.io.OutputStream>` | `swapOut()` Restores System.out and System.err to what they were before swappedIn() was called.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### private final boolean echoErr

    - #### private final boolean echoOut

    - #### protected boolean swapped

    - #### protected java.io.PrintStream swappedInErr

    - #### protected java.io.OutputStream swappedInErrStream

    - #### protected java.io.PrintStream swappedInOut

    - #### protected java.io.OutputStream swappedInOutStream

    - #### protected java.io.PrintStream swappedOutErr

    - #### protected java.io.PrintStream swappedOutOut

  - ### Property Detail

    - #### final boolean echoErr

    - #### final boolean echoOut

  - ### Constructor Detail

    - #### SystemOutAndErrSwapper(boolean echoOut, boolean echoErr)

  - ### Method Detail

    - #### boolean isSwapped()

    - #### java.util.List<java.io.OutputStream> swapIn()

      Replaces System.out and System.err with PrintStream's wrapping outStream and errStream

      throws:
        IllegalStateException if a swap is already on
      Returns:
        [outStream, errStream]

    - #### java.util.List<java.io.OutputStream> swapIn(java.io.OutputStream outStream, java.io.OutputStream errStream)

      Replaces System.out and System.err with PrintStream's wrapping outStream and errStream

      throws:
        IllegalStateException if a swap is already on
      Returns:
        [outStream, errStream]

    - #### java.util.List<java.io.OutputStream> swapOut()

      Restores System.out and System.err to what they were before swappedIn() was called.

      throws:
        IllegalStateException if not in a swap
      Returns:
        the underlying output streams for the swap ([out, err])