Groovy Documentation

org.codehaus.groovy.grails.test.io
[Groovy] Class SystemOutAndErrSwapper

java.lang.Object
  org.codehaus.groovy.grails.test.io.SystemOutAndErrSwapper

class SystemOutAndErrSwapper
extends java.lang.Object

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


Field Summary
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 Summary
boolean echoErr

boolean echoOut

 
Constructor Summary
SystemOutAndErrSwapper(boolean echoOut = false, boolean echoErr = false)

 
Method Summary
java.util.List swapIn()

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

java.util.List 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 swapOut()

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

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

swapped

protected boolean swapped


swappedInErr

protected java.io.PrintStream swappedInErr


swappedInErrStream

protected java.io.OutputStream swappedInErrStream


swappedInOut

protected java.io.PrintStream swappedInOut


swappedInOutStream

protected java.io.OutputStream swappedInOutStream


swappedOutErr

protected java.io.PrintStream swappedOutErr


swappedOutOut

protected java.io.PrintStream swappedOutOut


 
Property Detail

echoErr

final boolean echoErr


echoOut

final boolean echoOut


 
Constructor Detail

SystemOutAndErrSwapper

SystemOutAndErrSwapper(boolean echoOut = false, boolean echoErr = false)


 
Method Detail

swapIn

java.util.List 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]


swapIn

java.util.List 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]


swapOut

java.util.List 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])


 

Groovy Documentation