Exemplo n.º 1
0
 /**
  * Test of getNbFiles method, of class ZipManager.
  *
  * @throws Exception
  */
 @Test
 public void testGetNbFiles() throws Exception {
   File path = new File(mavenTargetDirectoryRule.getResourceTestDirFile(), "ZipSample");
   File outfile = new File(tempDir, "testGetNbFiles.zip");
   ZipUtil.compressPathToZip(path, outfile);
   assertThat(outfile, is(notNullValue()));
   assertThat(outfile.exists(), is(true));
   assertThat(outfile.isFile(), is(true));
   int result = ZipUtil.getNbFiles(outfile);
   assertThat(result, is(5));
 }
Exemplo n.º 2
0
 /**
  * Test of compressStreamToZip method, of class ZipManager.
  *
  * @throws Exception
  */
 @Test
 public void testCompressStreamToZip() throws Exception {
   InputStream inputStream =
       this.getClass().getClassLoader().getResourceAsStream("FrenchScrum.odp");
   String filePathNameToCreate =
       separatorChar + "dir1" + separatorChar + "dir2" + separatorChar + "FrenchScrum.odp";
   File outfile = new File(tempDir, "testCompressStreamToZip.zip");
   ZipUtil.compressStreamToZip(inputStream, filePathNameToCreate, outfile.getPath());
   inputStream.close();
   assertThat(outfile, is(notNullValue()));
   assertThat(outfile.exists(), is(true));
   assertThat(outfile.isFile(), is(true));
   int result = ZipUtil.getNbFiles(outfile);
   assertThat(result, is(1));
   ZipFile zipFile = new ZipFile(outfile);
   assertThat(zipFile.getEntry("/dir1/dir2/FrenchScrum.odp"), is(notNullValue()));
   zipFile.close();
 }