Please provide pointers to help me mock that java InputStream object. This is the line of code that I would wish to Mock:
InputStreamReader inputData = new InputStreamReader(System.in); bufferdReader = new BufferedReader(inputData); bufferdReader.readLine();
We can convert a String to an InputStream object by using the ByteArrayInputStream class. This class constructor takes the string byte array which can be done by calling the getBytes() method of a String class.
You could use commons-io to create some stub input streams:
InputStream stubInputStream = IOUtils.toInputStream("some test data for my input stream", "UTF-8");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With