Class SystemInMock
- java.lang.Object
-
- java.io.InputStream
-
- ru.vyarus.dropwizard.guice.test.util.io.SystemInMock
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class SystemInMock extends java.io.InputStream
System in mock implementation. Should be used to substitute system input stream in order to mock user input in tests.SystemInMock in = new SystemInMock(); System.setIn(in); in.provideText(..);
.Error would be thrown in case of not enough user inputs provided.
Original code taken from System rules library (see TextFromStandardInputStream) with some modifications.
- Since:
- 20.11.2023
-
-
Constructor Summary
Constructors Constructor Description SystemInMock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getReads()
void
provideText(java.lang.String... lines)
int
read()
int
read(byte[] buffer, int offset, int len)
-
-
-
Method Detail
-
provideText
public void provideText(java.lang.String... lines)
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] buffer, int offset, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
getReads
public int getReads()
- Returns:
- count of user input requests
-
-