StreamCopier extends ComponentSupport { public T read() { return read(60000); } StreamCopier(final Consumer<OutputStream> write, final Function<InputStream, T> read);  StreamCopier(final Consumer<OutputStream> write,
                      final Function<InputStream, T> read,
                      final ExecutorService service); T read(); T read(final long timeoutMilliseconds); StreamCopier<T> afterReadLeaveStreamsOpen();  }
@Test public void when_Read_Simple_Expect_Valid_Output() { underTest = new StreamCopier<>(outputStream -> { }, inputStream -> DEFAULT_READ_OUTPUT); assertThat(underTest.read(), is(equalTo(DEFAULT_READ_OUTPUT))); }
@Test public void when_Write_To_OutputStream_Expect_To_Read_Written_Value_Multiple_Times() { underTest = new StreamCopier<>(this::writeString, this::readString); assertThat(underTest.read(), is(equalTo(DEFAULT_READ_OUTPUT))); assertThat(underTest.read(), is(equalTo(DEFAULT_READ_OUTPUT))); }
@Test public void when_Write_Throws_Exception_Expect_Fail_To_Read_Value() { expectedException.expect(RuntimeException.class); expectedException.expectMessage("Unable to properly read from stream"); underTest = new StreamCopier<>(outputStream -> { throw new RuntimeException("Test witting failure"); }, this::readString); underTest.read(1000); }
@Test public void when_Read_Throws_Exception_Expect_Fail_To_Read_Value() { expectedException.expect(RuntimeException.class); expectedException.expectMessage("Unable to properly read from stream"); underTest = new StreamCopier<>(this::writeString, inputStream -> { throw new RuntimeException("Test Reading failure"); }); underTest.read(1000); }