Package org.elasticsearch.cli
Class MockTerminal
java.lang.Object
org.elasticsearch.cli.Terminal
org.elasticsearch.cli.MockTerminal
public class MockTerminal
extends org.elasticsearch.cli.Terminal
A terminal for tests which captures all output, and
can be plugged with fake input.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.cli.Terminal
org.elasticsearch.cli.Terminal.Verbosity -
Field Summary
Fields inherited from class org.elasticsearch.cli.Terminal
DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSecretInput(String input) Adds an an input that will be return fromreadSecret(String).voidaddTextInput(String input) Adds an an input that will be return fromreadText(String).Returns all output written to this terminal.Returns all output written to this terminal.byte[]Returns all bytes written to this terminal.char[]readSecret(String prompt) voidreset()Wipes the input and output.voidsetHasOutputStream(boolean hasOutputStream) Methods inherited from class org.elasticsearch.cli.Terminal
errorPrint, errorPrintln, errorPrintln, flush, isHeadless, isPrintable, print, print, println, println, promptYesNo, readLineToCharArray, readSecret, setVerbosity
-
Constructor Details
-
MockTerminal
public MockTerminal()
-
-
Method Details
-
readText
- Specified by:
readTextin classorg.elasticsearch.cli.Terminal
-
readSecret
- Specified by:
readSecretin classorg.elasticsearch.cli.Terminal
-
getWriter
- Specified by:
getWriterin classorg.elasticsearch.cli.Terminal
-
getOutputStream
- Specified by:
getOutputStreamin classorg.elasticsearch.cli.Terminal
-
getErrorWriter
- Overrides:
getErrorWriterin classorg.elasticsearch.cli.Terminal
-
setHasOutputStream
public void setHasOutputStream(boolean hasOutputStream) -
addTextInput
Adds an an input that will be return fromreadText(String). Values are read in FIFO order. -
addSecretInput
Adds an an input that will be return fromreadSecret(String). Values are read in FIFO order. -
getOutput
Returns all output written to this terminal.- Throws:
UnsupportedEncodingException
-
getOutputBytes
public byte[] getOutputBytes()Returns all bytes written to this terminal. -
getErrorOutput
Returns all output written to this terminal.- Throws:
UnsupportedEncodingException
-
reset
public void reset()Wipes the input and output.
-