StringToArchive implements ItemToArchive { @Override public InputStream getInputStream() throws IOException { return new ByteArrayInputStream(string.getBytes()); } StringToArchive(String pathInZip, String string); @Override boolean isDirectory(); @Override InputStream getInputStream(); @Override String getPathInZip(); @Override long getSize();  }
@Test public void testFileToArchiveReturnsCorrectStream() throws Exception { StringToArchive fileToArchive = new StringToArchive("", EXAMPLE_CONTENT); assertEquals(EXAMPLE_CONTENT, IOUtils.toString(fileToArchive.getInputStream())); }