private void assertZipAndUnzipOfDirectoryMatchesOriginal(File sourceDir) throws IOException {
  File[] sourceFiles=sourceDir.listFiles();
  Arrays.sort(sourceFiles);
  File zipFile=createZipFileHandle();
  ZipFiles.zipDirectory(sourceDir,zipFile);
  File outputDir=Files.createTempDir();
  ZipFiles.unzipFile(zipFile,outputDir);
  File[] outputFiles=outputDir.listFiles();
  Arrays.sort(outputFiles);
  assertThat(outputFiles,arrayWithSize(sourceFiles.length));
  for (int i=0; i < sourceFiles.length; i++) {
    compareFileContents(sourceFiles[i],outputFiles[i]);
  }
  removeRecursive(outputDir.toPath());
  assertTrue(zipFile.delete());
}

private void assertZipAndUnzipOfDirectoryMatchesOriginal ( File sourceDir ) throws IOException { File [ ] sourceFiles = sourceDir . listFiles ( ) ; Arrays . sort ( sourceFiles ) ; File zipFile = createZipFileHandle ( ) ; ZipFiles . zipDirectory ( sourceDir , zipFile ) ; File outputDir = Files . createTempDir ( ) ; ZipFiles . unzipFile ( zipFile , outputDir ) ; File [ ] outputFiles = outputDir . listFiles ( ) ; Arrays . sort ( outputFiles ) ; assertThat ( outputFiles , arrayWithSize ( sourceFiles . length ) ) ; for ( int i = 0 ; i < sourceFiles . length ; i ++ ) { compareFileContents ( sourceFiles [ i ] , outputFiles [ i ] ) ; } removeRecursive ( outputDir . toPath ( ) ) ; assertTrue ( zipFile . delete ( ) ) ; }
zip and unzip a certain directory , and verify the content afterward to be identical .
