Author: bodewig Date: Sun Jul 31 19:12:05 2011 New Revision: 1152617 URL: http://svn.apache.org/viewvc?rev=1152617&view=rev Log: whitespace only
Modified: commons/proper/compress/branches/zip64/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java Modified: commons/proper/compress/branches/zip64/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java URL: http://svn.apache.org/viewvc/commons/proper/compress/branches/zip64/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java?rev=1152617&r1=1152616&r2=1152617&view=diff ============================================================================== --- commons/proper/compress/branches/zip64/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java (original) +++ commons/proper/compress/branches/zip64/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java Sun Jul 31 19:12:05 2011 @@ -653,152 +653,141 @@ public class Zip64SupportTest { */ private static ZipOutputTest writeBigDeflatedEntryToFile(final boolean knownSize) { return new ZipOutputTest() { - public void test(File f, - ZipArchiveOutputStream zos) - throws IOException { - byte[] buf = new byte[1000 * 1000]; - ZipArchiveEntry zae = - new ZipArchiveEntry("0"); - if (knownSize) { - zae.setSize(FIVE_BILLION); - } - zae.setMethod(ZipArchiveEntry.DEFLATED); - zos.putArchiveEntry(zae); - for (int j = 0; - j < FIVE_BILLION / 1000 / 1000; - j++) { - zos.write(buf); - } - zos.closeArchiveEntry(); - zos.close(); - - RandomAccessFile a = - new RandomAccessFile(f, "r"); - try { - final long end = - getLengthAndPositionAtCentralDirectory(a); - - long cfhPos = a.getFilePointer(); - // grab first entry, verify - // sizes are 0xFFFFFFFF and - // it has a ZIP64 extended - // information extra field - byte[] header = new byte[12]; - a.readFully(header); - assertArrayEquals(new byte[] { - // sig - (byte) 0x50, (byte) 0x4b, 1, 2, - // version made by - 45, 0, - // version needed to extract - 45, 0, - // GPB (EFS + *no* Data - // Descriptor) - 0, 8, - // method - 8, 0, - }, header); - // ignore timestamp - a.skipBytes(4); - byte[] rest = new byte[31]; - a.readFully(rest); - assertArrayEquals(new byte[] { - // CRC - (byte) 0x50, (byte) 0x6F, - (byte) 0x31, (byte) 0x5c, - // Compressed Size - (byte) 0xFF, (byte) 0xFF, - (byte) 0xFF, (byte) 0xFF, - // Original Size - (byte) 0xFF, (byte) 0xFF, - (byte) 0xFF, (byte) 0xFF, - // file name length - 1, 0, - // extra field length - 20, 0, - // comment length - 0, 0, - // disk number - 0, 0, - // attributes - 0, 0, - 0, 0, 0, 0, - // offset - 0, 0, 0, 0, - // file name - (byte) '0' - }, rest); - byte[] extra = new byte[12]; - a.readFully(extra); - // 5e9 == 0x12A05F200 - assertArrayEquals(new byte[] { - // Header-ID - 1, 0, - // size of extra - 16, 0, - // original size - 0, (byte) 0xF2, 5, (byte) 0x2A, - 1, 0, 0, 0, - // don't know the - // compressed size, - // don't want to - // hard-code it - }, extra); - - // and now validate local file header - a.seek(0); - header = new byte[10]; - a.readFully(header); - assertArrayEquals(new byte[] { - // sig - (byte) 0x50, (byte) 0x4b, 3, 4, - // version needed to extract - 45, 0, - // GPB (EFS bit, no DD) - 0, 8, - // method - 8, 0, - }, header); - // ignore timestamp - a.skipBytes(4); - rest = new byte[17]; - a.readFully(rest); - assertArrayEquals(new byte[] { - // CRC - (byte) 0x50, (byte) 0x6F, - (byte) 0x31, (byte) 0x5c, - // Compressed Size - (byte) 0xFF, (byte) 0xFF, - (byte) 0xFF, (byte) 0xFF, - // Original Size - (byte) 0xFF, (byte) 0xFF, - (byte) 0xFF, (byte) 0xFF, - // file name length - 1, 0, - // extra field length - 20, 0, - // file name - (byte) '0' - }, rest); - extra = new byte[12]; - a.readFully(extra); - assertArrayEquals(new byte[] { - // Header-ID - 1, 0, - // size of extra - 16, 0, - // original size - 0, (byte) 0xF2, 5, (byte) 0x2A, - 1, 0, 0, 0, - // don't know the - // compressed size, - // don't want to - // hard-code it - }, extra); - } finally { - a.close(); - } - } + public void test(File f, ZipArchiveOutputStream zos) + throws IOException { + byte[] buf = new byte[1000 * 1000]; + ZipArchiveEntry zae = new ZipArchiveEntry("0"); + if (knownSize) { + zae.setSize(FIVE_BILLION); + } + zae.setMethod(ZipArchiveEntry.DEFLATED); + zos.putArchiveEntry(zae); + for (int j = 0; + j < FIVE_BILLION / 1000 / 1000; + j++) { + zos.write(buf); + } + zos.closeArchiveEntry(); + zos.close(); + + RandomAccessFile a = new RandomAccessFile(f, "r"); + try { + final long end = getLengthAndPositionAtCentralDirectory(a); + + long cfhPos = a.getFilePointer(); + // grab first entry, verify + // sizes are 0xFFFFFFFF and + // it has a ZIP64 extended + // information extra field + byte[] header = new byte[12]; + a.readFully(header); + assertArrayEquals(new byte[] { + // sig + (byte) 0x50, (byte) 0x4b, 1, 2, + // version made by + 45, 0, + // version needed to extract + 45, 0, + // GPB (EFS + *no* Data Descriptor) + 0, 8, + // method + 8, 0, + }, header); + // ignore timestamp + a.skipBytes(4); + byte[] rest = new byte[31]; + a.readFully(rest); + assertArrayEquals(new byte[] { + // CRC + (byte) 0x50, (byte) 0x6F, (byte) 0x31, (byte) 0x5c, + // Compressed Size + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + // Original Size + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + // file name length + 1, 0, + // extra field length + 20, 0, + // comment length + 0, 0, + // disk number + 0, 0, + // attributes + 0, 0, + 0, 0, 0, 0, + // offset + 0, 0, 0, 0, + // file name + (byte) '0' + }, rest); + byte[] extra = new byte[12]; + a.readFully(extra); + // 5e9 == 0x12A05F200 + assertArrayEquals(new byte[] { + // Header-ID + 1, 0, + // size of extra + 16, 0, + // original size + 0, (byte) 0xF2, 5, (byte) 0x2A, + 1, 0, 0, 0, + // don't know the + // compressed size, + // don't want to + // hard-code it + }, extra); + + // and now validate local file header + a.seek(0); + header = new byte[10]; + a.readFully(header); + assertArrayEquals(new byte[] { + // sig + (byte) 0x50, (byte) 0x4b, 3, 4, + // version needed to extract + 45, 0, + // GPB (EFS bit, no DD) + 0, 8, + // method + 8, 0, + }, header); + // ignore timestamp + a.skipBytes(4); + rest = new byte[17]; + a.readFully(rest); + assertArrayEquals(new byte[] { + // CRC + (byte) 0x50, (byte) 0x6F, (byte) 0x31, (byte) 0x5c, + // Compressed Size + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + // Original Size + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, + // file name length + 1, 0, + // extra field length + 20, 0, + // file name + (byte) '0' + }, rest); + extra = new byte[12]; + a.readFully(extra); + assertArrayEquals(new byte[] { + // Header-ID + 1, 0, + // size of extra + 16, 0, + // original size + 0, (byte) 0xF2, 5, (byte) 0x2A, + 1, 0, 0, 0, + // don't know the + // compressed size, + // don't want to + // hard-code it + }, extra); + } finally { + a.close(); + } + } }; }