Package org.elasticsearch.cli
Class MockTerminal
java.lang.Object
org.elasticsearch.cli.Terminal
org.elasticsearch.cli.MockTerminal
public class MockTerminal extends Terminal
A terminal for tests which captures all output, and
can be plugged with fake input.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description MockTerminal()
-
Method Summary
Modifier and Type Method Description void
addSecretInput(java.lang.String input)
Adds an an input that will be return fromreadSecret(String)
.void
addTextInput(java.lang.String input)
Adds an an input that will be return fromreadText(String)
.java.lang.String
getErrorOutput()
Returns all output written to this terminal.java.io.PrintWriter
getErrorWriter()
java.lang.String
getOutput()
Returns all output written to this terminal.java.io.PrintWriter
getWriter()
char[]
readSecret(java.lang.String prompt)
java.lang.String
readText(java.lang.String prompt)
void
reset()
Wipes the input and output.Methods inherited from class org.elasticsearch.cli.Terminal
errorPrint, errorPrintln, errorPrintln, flush, isPrintable, print, println, println, promptYesNo, readLineToCharArray, readSecret, setVerbosity
-
Constructor Details
-
MockTerminal
public MockTerminal()
-
-
Method Details
-
readText
public java.lang.String readText(java.lang.String prompt) -
readSecret
public char[] readSecret(java.lang.String prompt)- Specified by:
readSecret
in classTerminal
-
getWriter
public java.io.PrintWriter getWriter() -
getErrorWriter
public java.io.PrintWriter getErrorWriter()- Overrides:
getErrorWriter
in classTerminal
-
addTextInput
public void addTextInput(java.lang.String input)Adds an an input that will be return fromreadText(String)
. Values are read in FIFO order. -
addSecretInput
public void addSecretInput(java.lang.String input)Adds an an input that will be return fromreadSecret(String)
. Values are read in FIFO order. -
getOutput
public java.lang.String getOutput() throws java.io.UnsupportedEncodingExceptionReturns all output written to this terminal.- Throws:
java.io.UnsupportedEncodingException
-
getErrorOutput
public java.lang.String getErrorOutput() throws java.io.UnsupportedEncodingExceptionReturns all output written to this terminal.- Throws:
java.io.UnsupportedEncodingException
-
reset
public void reset()Wipes the input and output.
-