### Question:
JarUnpacker implements Unpacker { @Override public Path unpack(Path jarFilePath) throws IOException { Path destDirPath = Files.createTempDirectory(unpackedDirectoryPrefix); try ( JarFile jar = new JarFile(jarFilePath.toFile())) { for (Enumeration<JarEntry> enums = jar.entries(); enums.hasMoreElements(); ) { JarEntry entry = enums.nextElement(); String fileName = destDirPath.toAbsolutePath() + File.separator + entry.getName(); File f = new File(fileName); if (fileName.endsWith("/") || entry.isDirectory()) { f.mkdirs(); } } for (Enumeration<JarEntry> enums = jar.entries(); enums.hasMoreElements(); ) { JarEntry entry = enums.nextElement(); String fileName = destDirPath.toAbsolutePath().toString() + File.separator + entry.getName(); File f = new File(fileName); if (!fileName.endsWith("/") && !entry.isDirectory()) { if (!f.getParentFile().exists()) { f.getParentFile().mkdirs(); } try (InputStream is = jar.getInputStream(entry)) { copyPath(is, f); } } } return destDirPath; } } JarUnpacker(String unpackedDirectoryPrefix); @Override Path unpack(Path jarFilePath);  }### Answer:
@Test public void testUnpack() throws IOException { try ( OutputStream outputStream = Files.newOutputStream(tempJar); JarGenerator generator = new JarGenerator(outputStream)) { generator.generate(); } Unpacker unpacker = new JarUnpacker(""); unpackedFile = unpacker.unpack(tempJar); try (JarFile jarFile = new JarFile(tempJar.toFile())) { Map<String, Long> files = new HashMap<>(); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry jarEntry = entries.nextElement(); files.put(jarEntry.getName(), jarEntry.getSize()); } Path finalUnpackedFile = unpackedFile; Files.walkFileTree(unpackedFile, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { Path unpackedFile = finalUnpackedFile.relativize(file); assertTrue(files.containsKey(unpackedFile.toString().replaceAll("\\\\", "/"))); return FileVisitResult.CONTINUE; } }); } }