InputStreamArchiveFile extends ArchiveFile { public InputStream toStream() throws IOException { return new ByteArrayInputStream(streamData.clone()); } InputStreamArchiveFile(String mimeType, String location, InputStream stream); InputStream toStream(); File copyStreamToDirectory(String directory);  }
@Test public void test_toStream_returns_value() throws IOException { InputStream inputStream = new FileInputStream(new File(TEST_DIRECTORY + "/" + FILE_NAME)); ArchiveFile archiveFile = new InputStreamArchiveFile("mime", FILE_NAME, inputStream); assertThat(archiveFile.getFileName(), is(equalTo(FILE_NAME))); assertThat(archiveFile.toStream(), is(instanceOf(InputStream.class))); }
@Test public void test_stream_remains_open_after_multiple_calls_to_toStream() throws IOException { File file = new File(TEST_DIRECTORY + "/" + FILE_NAME); if (!file.exists()) throw new RuntimeException("file not found"); FileInputStream fis = new FileInputStream(file); InputStreamArchiveFile archiveFile = new InputStreamArchiveFile("mime", FILE_NAME, fis); archiveFile.toStream(); archiveFile.toStream(); }