@Test public void testAddFileToArchive() throws Exception { fileToArchiveWriter.addFileToArchive(fileToAddIntoArchive.toPath(), archiveToAddFileIn.toPath(), innerPath); List<String> filesInZip = listContentsOfZip(archiveToAddFileIn); assertThat(filesInZip.stream().map(Paths::get)).contains(innerPath); originalContentOfZip.forEach( f -> assertThat(filesInZip).contains(f)); String contentOfAddedFile = getContentOfEntryInZip(archiveToAddFileIn, innerPath.toString()); assertThat(contentOfAddedFile).isEqualTo(contentOfInnerFile); }
public void addFileToArchive(Path sourcePath, Path zipFile, Path pathInArchive) { if (pathInArchive == null){ throw new ExecutionException("The argument pathInArchive was empty"); } if(sourcePath == null) { throw new ExecutionException("The argument sourcePath was empty"); } if(! sourcePath.toFile().exists()){ throw new ExecutionException("Source file=["+sourcePath+"] does not exist"); } try { addNewEntryToZipFile(zipFile, pathInArchive, sourcePath); } catch (IOException | URISyntaxException e) { throw new ExecutionException("The file=[" + sourcePath + "] could not be added to the archive=[" + zipFile + "]", e); } }
FileToArchiveWriter extends AbstractOutputHandler { public void addFileToArchive(Path sourcePath, Path zipFile, Path pathInArchive) { if (pathInArchive == null){ throw new ExecutionException("The argument pathInArchive was empty"); } if(sourcePath == null) { throw new ExecutionException("The argument sourcePath was empty"); } if(! sourcePath.toFile().exists()){ throw new ExecutionException("Source file=["+sourcePath+"] does not exist"); } try { addNewEntryToZipFile(zipFile, pathInArchive, sourcePath); } catch (IOException | URISyntaxException e) { throw new ExecutionException("The file=[" + sourcePath + "] could not be added to the archive=[" + zipFile + "]", e); } } }
FileToArchiveWriter extends AbstractOutputHandler { public void addFileToArchive(Path sourcePath, Path zipFile, Path pathInArchive) { if (pathInArchive == null){ throw new ExecutionException("The argument pathInArchive was empty"); } if(sourcePath == null) { throw new ExecutionException("The argument sourcePath was empty"); } if(! sourcePath.toFile().exists()){ throw new ExecutionException("Source file=["+sourcePath+"] does not exist"); } try { addNewEntryToZipFile(zipFile, pathInArchive, sourcePath); } catch (IOException | URISyntaxException e) { throw new ExecutionException("The file=[" + sourcePath + "] could not be added to the archive=[" + zipFile + "]", e); } } FileToArchiveWriter(); }
FileToArchiveWriter extends AbstractOutputHandler { public void addFileToArchive(Path sourcePath, Path zipFile, Path pathInArchive) { if (pathInArchive == null){ throw new ExecutionException("The argument pathInArchive was empty"); } if(sourcePath == null) { throw new ExecutionException("The argument sourcePath was empty"); } if(! sourcePath.toFile().exists()){ throw new ExecutionException("Source file=["+sourcePath+"] does not exist"); } try { addNewEntryToZipFile(zipFile, pathInArchive, sourcePath); } catch (IOException | URISyntaxException e) { throw new ExecutionException("The file=[" + sourcePath + "] could not be added to the archive=[" + zipFile + "]", e); } } FileToArchiveWriter(); @Override void handle(Map<String, IAttachable> generatedOutput); @Override void configure(Map<String, String> configMap); void addFileToArchive(Path sourcePath, Path zipFile, Path pathInArchive); }
FileToArchiveWriter extends AbstractOutputHandler { public void addFileToArchive(Path sourcePath, Path zipFile, Path pathInArchive) { if (pathInArchive == null){ throw new ExecutionException("The argument pathInArchive was empty"); } if(sourcePath == null) { throw new ExecutionException("The argument sourcePath was empty"); } if(! sourcePath.toFile().exists()){ throw new ExecutionException("Source file=["+sourcePath+"] does not exist"); } try { addNewEntryToZipFile(zipFile, pathInArchive, sourcePath); } catch (IOException | URISyntaxException e) { throw new ExecutionException("The file=[" + sourcePath + "] could not be added to the archive=[" + zipFile + "]", e); } } FileToArchiveWriter(); @Override void handle(Map<String, IAttachable> generatedOutput); @Override void configure(Map<String, String> configMap); void addFileToArchive(Path sourcePath, Path zipFile, Path pathInArchive);  }