public static class SystemLambda.SystemInStub extends Object
System.in. The methods
andExceptionThrownOnInputEnd(IOException) and
andExceptionThrownOnInputEnd(RuntimeException) can be used to
simulate a System.in that throws an exception.
The specified behaviour of System.in is applied to an
arbitrary piece of code that is provided to execute(Statement).
| Modifier and Type | Method and Description |
|---|---|
SystemLambda.SystemInStub |
andExceptionThrownOnInputEnd(IOException exception)
Sets an exception that is thrown after the text is read.
|
SystemLambda.SystemInStub |
andExceptionThrownOnInputEnd(RuntimeException exception)
Sets an exception that is thrown after the text is read.
|
void |
execute(Statement statement)
Executes the statement and lets
System.in provide the
specified text during the execution. |
public SystemLambda.SystemInStub andExceptionThrownOnInputEnd(IOException exception)
exception - the IOException to be thrown.SystemInStub itself.IllegalStateException - if a RuntimeException was
already set by
andExceptionThrownOnInputEnd(RuntimeException)public SystemLambda.SystemInStub andExceptionThrownOnInputEnd(RuntimeException exception)
exception - the RuntimeException to be thrown.SystemInStub itself.IllegalStateException - if an IOException was already
set by andExceptionThrownOnInputEnd(IOException)public void execute(Statement statement) throws Exception
System.in provide the
specified text during the execution. After the text was read it
throws and exception when System.in#read is called and an
exception was specified by
andExceptionThrownOnInputEnd(IOException) or
andExceptionThrownOnInputEnd(RuntimeException).statement - an arbitrary piece of code.Exception - any exception thrown by the statement.Copyright © 2020. All rights reserved.