@Test public void testExecute() throws Exception { StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(); StepContribution stepContribution = new StepContribution(stepExecution); ChunkContext chunkContext = new ChunkContext(new StepContext(stepExecution)); RepeatStatus repeatStatus = tasklet.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(7, stepContribution.getWriteCount()); assertEquals(7, getFiles().count()); }
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputFile.getInputStream()))) { Path destinationPath = destinationFolder.getFile().toPath(); if (!Files.exists(destinationPath)) { Files.createDirectories(destinationPath); } for (ZipEntry entry = zis.getNextEntry() ; entry != null ; entry = zis.getNextEntry()) { Path outputFile = destinationPath.resolve(entry.getName()); Files.copy(zis, outputFile, StandardCopyOption.REPLACE_EXISTING); contribution.incrementWriteCount(1); } } return RepeatStatus.FINISHED; }
UnzipFileTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputFile.getInputStream()))) { Path destinationPath = destinationFolder.getFile().toPath(); if (!Files.exists(destinationPath)) { Files.createDirectories(destinationPath); } for (ZipEntry entry = zis.getNextEntry() ; entry != null ; entry = zis.getNextEntry()) { Path outputFile = destinationPath.resolve(entry.getName()); Files.copy(zis, outputFile, StandardCopyOption.REPLACE_EXISTING); contribution.incrementWriteCount(1); } } return RepeatStatus.FINISHED; } }
UnzipFileTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputFile.getInputStream()))) { Path destinationPath = destinationFolder.getFile().toPath(); if (!Files.exists(destinationPath)) { Files.createDirectories(destinationPath); } for (ZipEntry entry = zis.getNextEntry() ; entry != null ; entry = zis.getNextEntry()) { Path outputFile = destinationPath.resolve(entry.getName()); Files.copy(zis, outputFile, StandardCopyOption.REPLACE_EXISTING); contribution.incrementWriteCount(1); } } return RepeatStatus.FINISHED; }  }
UnzipFileTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputFile.getInputStream()))) { Path destinationPath = destinationFolder.getFile().toPath(); if (!Files.exists(destinationPath)) { Files.createDirectories(destinationPath); } for (ZipEntry entry = zis.getNextEntry() ; entry != null ; entry = zis.getNextEntry()) { Path outputFile = destinationPath.resolve(entry.getName()); Files.copy(zis, outputFile, StandardCopyOption.REPLACE_EXISTING); contribution.incrementWriteCount(1); } } return RepeatStatus.FINISHED; }  RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext); void setInputFile(Resource inputFile); void setDestinationFolder(Resource destinationFolder); }
UnzipFileTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { try (ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputFile.getInputStream()))) { Path destinationPath = destinationFolder.getFile().toPath(); if (!Files.exists(destinationPath)) { Files.createDirectories(destinationPath); } for (ZipEntry entry = zis.getNextEntry() ; entry != null ; entry = zis.getNextEntry()) { Path outputFile = destinationPath.resolve(entry.getName()); Files.copy(zis, outputFile, StandardCopyOption.REPLACE_EXISTING); contribution.incrementWriteCount(1); } } return RepeatStatus.FINISHED; }  RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext); void setInputFile(Resource inputFile); void setDestinationFolder(Resource destinationFolder);  }