ZipFiles { public String zipFile(String filePath) { try { OutputStream zipOutput = new FileOutputStream(new File(filePath + ".zip")); ArchiveOutputStream logicalZip = new ArchiveStreamFactory() .createArchiveOutputStream(ArchiveStreamFactory.ZIP, zipOutput); logicalZip.putArchiveEntry(new ZipArchiveEntry(FilenameUtils.getName(filePath))); IOUtils.copy(new FileInputStream(new File(filePath)), logicalZip); logicalZip.closeArchiveEntry(); logicalZip.finish(); zipOutput.close(); } catch (Exception e) { System.err.println(e.getMessage()); return null; } return filePath + ".zip"; }  String zipFile(String filePath);  }
@Test public void testZipFile_fixture_1() throws Exception { ZipFiles fixture2 = getFixture(); String filePath = "test.log"; File file = new File(filePath); file.createNewFile(); String result = fixture2.zipFile(filePath); file.delete(); file = new File(result); file.delete(); assertEquals("test.log.zip", result); }
@Test public void testZipFile_fixture_2() throws Exception { ZipFiles fixture2 = getFixture(); String filePath = "0123456789"; String result = fixture2.zipFile(filePath); File file = new File(filePath + ".zip"); file.delete(); assertEquals(null, result); }