EventStoreDownloadMojo extends AbstractEventStoreMojo { public static void unzip(final File zipFile, final File destDir) throws MojoExecutionException { try { final ZipFile zip = new ZipFile(zipFile); try { final Enumeration<? extends ZipEntry> enu = zip.entries(); while (enu.hasMoreElements()) { final ZipEntry entry = (ZipEntry) enu.nextElement(); final File file = new File(entry.getName()); if (file.isAbsolute()) { throw new IllegalArgumentException( "Only relative path entries are allowed! [" + entry.getName() + "]"); } if (entry.isDirectory()) { final File dir = new File(destDir, entry.getName()); mkDirsIfNecessary(dir); } else { LOG.info("Extracting: " + entry.getName()); final File outFile = new File(destDir, entry.getName()); mkDirsIfNecessary(outFile.getParentFile()); final InputStream in = new BufferedInputStream(zip.getInputStream(entry)); try { final OutputStream out = new BufferedOutputStream(new FileOutputStream(outFile)); try { final byte[] buf = new byte[4096]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } finally { out.close(); } } finally { in.close(); } } } } finally { zip.close(); } } catch (final IOException ex) { throw new MojoExecutionException("Error unzipping event store archive: " + zipFile, ex); } }  final File getDownloadFile(); static void unzip(final File zipFile, final File destDir); static void unTarGz(final File archive, final File destDir);  }
@Test public void testUnzip() throws MojoExecutionException, IOException { final String name = this.getClass().getSimpleName() + "-testUnzip"; final File archive = File.createTempFile(name + "-", ".zip"); final File destDir = new File(Utils4J.getTempDir(), name); init("example.zip", archive, destDir); EventStoreDownloadMojo.unzip(archive, destDir); assertAllExists(destDir); }