SystemOutAndErrSwapper (Grails 3.3.3)
Date: 2018-03-07

Package: org.grails.test.io

## [Groovy] Class SystemOutAndErrSwapper

- org.grails.test.io.SystemOutAndErrSwapper

- 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
    --- | --- | ---
    `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 = false, boolean echoErr = false)`

  - ### 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, int), java.lang.Object#wait(long), 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

    - #### 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 = false, boolean echoErr = false)

  - ### 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])