private static void assertUnicodeName(final ZipArchiveEntry ze,
final String expectedName,
final String encoding)
throws IOException {
if (!expectedName.equals(ze.getName())) {
final UnicodePathExtraField ucpf = findUniCodePath(ze);
assertNotNull(ucpf);
final ZipEncoding enc = ZipEncodingHelper.getZipEncoding(encoding);
final ByteBuffer ne = enc.encode(ze.getName());
final CRC32 crc = new CRC32();
crc.update(ne.array(), ne.arrayOffset(),
ne.limit() - ne.position());
assertEquals(crc.getValue(), ucpf.getNameCRC32());
assertEquals(expectedName, new String(ucpf.getUnicodeName(),
CharsetNames.UTF_8));
}
}
|