throws Exception {
File result = mkdir("dir-result");
result.deleteOnExit();
try {
ArchiveEntry entry = null;
while ((entry = in.getNextEntry()) != null) {
File outfile = new File(result.getCanonicalPath() + "/result/"
+ entry.getName());
long copied=0;
if (entry.isDirectory()){
outfile.mkdirs();
} else {
outfile.getParentFile().mkdirs();
OutputStream out = new FileOutputStream(outfile);
try {
copied=IOUtils.copy(in, out);
} finally {
out.close();
}
}
final long size = entry.getSize();
if (size != ArchiveEntry.SIZE_UNKNOWN) {
assertEquals("Entry.size should equal bytes read.",size, copied);
}
if (!outfile.exists()) {
fail("extraction failed: " + entry.getName());
}
if (expected != null && !expected.remove(getExpectedString(entry))) {
fail("unexpected entry: " + getExpectedString(entry));
}
}