use of org.apache.tools.zip.Zip64ExtendedInformationExtraField in project ant by apache.
the class ZipExtraFieldTest method testExtraField.
private void testExtraField(Zip testInstance, boolean expectZip64) throws IOException {
File f = File.createTempFile("ziptest", ".zip");
f.delete();
ZipFile zf = null;
try {
testInstance.setDestFile(f);
final ZipResource r = new ZipResource() {
public String getName() {
return "x";
}
public boolean isExists() {
return true;
}
public boolean isDirectory() {
return false;
}
public long getLastModified() {
return 1;
}
public InputStream getInputStream() {
return new ByteArrayInputStream(new byte[0]);
}
public ZipExtraField[] getExtraFields() {
return new ZipExtraField[] { new JarMarker() };
}
};
testInstance.add(new ResourceCollection() {
public boolean isFilesystemOnly() {
return false;
}
public int size() {
return 1;
}
public Iterator<Resource> iterator() {
return Collections.<Resource>singleton(r).iterator();
}
});
testInstance.execute();
zf = new ZipFile(f);
ZipEntry ze = zf.getEntry("x");
assertNotNull(ze);
assertEquals(expectZip64 ? 2 : 1, ze.getExtraFields().length);
assertTrue(ze.getExtraFields()[0] instanceof JarMarker);
if (expectZip64) {
assertTrue(ze.getExtraFields()[1] instanceof Zip64ExtendedInformationExtraField);
}
} finally {
ZipFile.closeQuietly(zf);
if (f.exists()) {
f.delete();
}
}
}
Aggregations