Zipper implements AutoCloseable { public void close() throws IOException { zip.flush(); zip.close(); } Zipper(OutputStream destStream); void addToZip(byte[] bytes, String destFilename); void addToZip(Path path, String destFilename); void addDirectoryToZip(final Path sourceDirectory,
                                  final PathPredicate directoryPredicate,
                                  final FilePredicate filePredicate,
                                  final String destinationDirectoryName); void close(); static final PathPredicate ALL_DIRECTORIES; static final FilePredicate ALL_FILES; }
@Test public void should_close_stream() throws Exception { ByteArrayOutputStream out = mock(ByteArrayOutputStream.class); Zipper zipper = new Zipper(out); zipper.close(); verify(out).flush(); verify(out).close(); }