Class SystemInMock
java.lang.Object
java.io.InputStream
ru.vyarus.dropwizard.guice.test.util.io.SystemInMock
- All Implemented Interfaces:
Closeable,AutoCloseable
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 -
Method Summary
Modifier and TypeMethodDescriptionintgetReads()voidprovideText(String... lines) intread()intread(byte[] buffer, int offset, int len) Methods inherited from class java.io.InputStream
available, close, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
SystemInMock
public SystemInMock()Create system in substitutor.
-
-
Method Details
-
provideText
- Parameters:
lines- mock system in source
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
getReads
public int getReads()- Returns:
- count of user input requests
-