commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1155302 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java
Date Tue, 09 Aug 2011 10:39:19 GMT
Author: bodewig
Date: Tue Aug  9 10:39:18 2011
New Revision: 1155302

URL: http://svn.apache.org/viewvc?rev=1155302&view=rev
Log:
whitespace changes and updated comments in test

Modified:
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java?rev=1155302&r1=1155301&r2=1155302&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportTest.java
Tue Aug  9 10:39:18 2011
@@ -49,78 +49,78 @@ public class Zip64SupportTest {
     private static final int ONE_HUNDRED_THOUSAND = 100000;
 
     @Ignore
-    @Test public void read5GBOfZerosUsingInputStream() throws Throwable {
+        @Test public void read5GBOfZerosUsingInputStream() throws Throwable {
         read5GBOfZerosImpl(get5GBZerosFile(), "5GB_of_Zeros");
     }
 
     @Ignore
-    @Test public void read5GBOfZerosGeneratedBy7ZIPUsingInputStream()
+        @Test public void read5GBOfZerosGeneratedBy7ZIPUsingInputStream()
         throws Throwable {
         read5GBOfZerosImpl(get5GBZerosFileGeneratedBy7ZIP(), "5GB_of_Zeros");
     }
 
     @Ignore
-    @Test public void read5GBOfZerosGeneratedByJava7JarUsingInputStream()
+        @Test public void read5GBOfZerosGeneratedByJava7JarUsingInputStream()
         throws Throwable {
         read5GBOfZerosImpl(get5GBZerosFileGeneratedByJava7Jar(), "5GB_of_Zeros");
     }
 
     @Ignore
-    @Test public void read100KFilesUsingInputStream() throws Throwable {
+        @Test public void read100KFilesUsingInputStream() throws Throwable {
         read100KFilesImpl(get100KFileFile());
     }
 
     @Ignore
-    @Test public void read100KFilesGeneratedBy7ZIPUsingInputStream() throws Throwable {
+        @Test public void read100KFilesGeneratedBy7ZIPUsingInputStream() throws Throwable
{
         read100KFilesImpl(get100KFileFileGeneratedBy7ZIP());
     }
 
     @Ignore
-    @Test public void read100KFilesGeneratedByWinCFUsingInputStream() throws Throwable {
+        @Test public void read100KFilesGeneratedByWinCFUsingInputStream() throws Throwable
{
         read100KFilesImpl(get100KFileFileGeneratedByWinCF());
     }
 
     @Ignore
-    @Test public void read100KFilesGeneratedByJava7JarUsingInputStream() throws Throwable
{
+        @Test public void read100KFilesGeneratedByJava7JarUsingInputStream() throws Throwable
{
         read100KFilesImpl(get100KFileFileGeneratedByJava7Jar());
     }
 
     @Ignore
-    @Test public void read5GBOfZerosUsingZipFile() throws Throwable {
+        @Test public void read5GBOfZerosUsingZipFile() throws Throwable {
         read5GBOfZerosUsingZipFileImpl(get5GBZerosFile(), "5GB_of_Zeros");
     }
 
     @Ignore
-    @Test public void read5GBOfZerosGeneratedBy7ZIPUsingZipFile()
+        @Test public void read5GBOfZerosGeneratedBy7ZIPUsingZipFile()
         throws Throwable {
         read5GBOfZerosUsingZipFileImpl(get5GBZerosFileGeneratedBy7ZIP(),
                                        "5GB_of_Zeros");
     }
 
     @Ignore
-    @Test public void read5GBOfZerosGeneratedByJava7JarUsingZipFile()
+        @Test public void read5GBOfZerosGeneratedByJava7JarUsingZipFile()
         throws Throwable {
         read5GBOfZerosUsingZipFileImpl(get5GBZerosFileGeneratedByJava7Jar(),
                                        "5GB_of_Zeros");
     }
 
     @Ignore
-    @Test public void read100KFilesUsingZipFile() throws Throwable {
+        @Test public void read100KFilesUsingZipFile() throws Throwable {
         read100KFilesUsingZipFileImpl(get100KFileFile());
     }
 
     @Ignore
-    @Test public void read100KFilesGeneratedBy7ZIPUsingZipFile() throws Throwable {
+        @Test public void read100KFilesGeneratedBy7ZIPUsingZipFile() throws Throwable {
         read100KFilesUsingZipFileImpl(get100KFileFileGeneratedBy7ZIP());
     }
 
     @Ignore
-    @Test public void read100KFilesGeneratedByWinCFUsingZipFile() throws Throwable {
+        @Test public void read100KFilesGeneratedByWinCFUsingZipFile() throws Throwable {
         read100KFilesUsingZipFileImpl(get100KFileFileGeneratedByWinCF());
     }
 
     @Ignore
-    @Test public void read100KFilesGeneratedByJava7JarUsingZipFile() throws Throwable {
+        @Test public void read100KFilesGeneratedByJava7JarUsingZipFile() throws Throwable
{
         read100KFilesUsingZipFileImpl(get100KFileFileGeneratedByJava7Jar());
     }
 
@@ -253,7 +253,7 @@ public class Zip64SupportTest {
     }
 
     @Ignore
-    @Test public void readSelfGenerated100KFilesUsingZipFile()
+        @Test public void readSelfGenerated100KFilesUsingZipFile()
         throws Throwable {
         withTemporaryArchive("readSelfGenerated100KFilesUsingZipFile()",
                              new ZipOutputTest() {
@@ -396,7 +396,7 @@ public class Zip64SupportTest {
     }
 
     @Ignore
-    @Test public void read3EntriesCreatingBigArchiveFileUsingZipFile()
+        @Test public void read3EntriesCreatingBigArchiveFileUsingZipFile()
         throws Throwable {
         withTemporaryArchive("read3EntriesCreatingBigArchiveFileUsingZipFile",
                              new ZipOutputTest() {
@@ -1069,19 +1069,19 @@ public class Zip64SupportTest {
                              true);
     }
 
+    private static ZipOutputTest writeSmallStoredEntry(final boolean knownSize) {
+        return writeSmallStoredEntry(knownSize, Zip64Mode.AsNeeded);
+    }
+
     /*
      * One entry of length 1 million bytes, written without compression.
      *
      * No Compression => sizes are stored directly inside the LFH.  No
      * Data Descriptor at all.  Shouldn't contain any ZIP64 extra
-     * field if size was known.
+     * field if size was known and mode was different from Always.
      *
      * Creates a temporary archive of approx 1MB in size
      */
-    private static ZipOutputTest writeSmallStoredEntry(final boolean knownSize) {
-        return writeSmallStoredEntry(knownSize, Zip64Mode.AsNeeded);
-    }
-
     private static ZipOutputTest writeSmallStoredEntry(final boolean knownSize,
                                                        final Zip64Mode mode) {
         return new ZipOutputTest() {
@@ -1251,139 +1251,137 @@ public class Zip64SupportTest {
                              true);
     }
 
+    /*
+     * One entry of length 1 million bytes, written with compression
+     * to a stream.
+     *
+     * Compression + Stream => sizes are set to 0 in LFH, real values
+     * are inside the data descriptor.  No ZIP64 extra field at all
+     * unless mode is Always.
+     */
     private static ZipOutputTest
         writeSmallDeflatedEntryKnownSizeToStream(final Zip64Mode mode) {
         return new ZipOutputTest() {
-                                 public void test(File f,
-                                                  ZipArchiveOutputStream zos)
-                                     throws IOException {
+            public void test(File f, ZipArchiveOutputStream zos)
+                throws IOException {
                 if (mode != Zip64Mode.AsNeeded) {
                     zos.setUseZip64(mode);
                 }
-                                     byte[] buf = new byte[ONE_MILLION];
-                                     ZipArchiveEntry zae =
-                                         new ZipArchiveEntry("0");
-                                     zae.setSize(ONE_MILLION);
-                                     zae.setMethod(ZipArchiveEntry.DEFLATED);
-                                     zos.putArchiveEntry(zae);
-                                     zos.write(buf);
-                                     zos.closeArchiveEntry();
-                                     zos.close();
+                byte[] buf = new byte[ONE_MILLION];
+                ZipArchiveEntry zae = new ZipArchiveEntry("0");
+                zae.setSize(ONE_MILLION);
+                zae.setMethod(ZipArchiveEntry.DEFLATED);
+                zos.putArchiveEntry(zae);
+                zos.write(buf);
+                zos.closeArchiveEntry();
+                zos.close();
 
-                                     RandomAccessFile a =
-                                         new RandomAccessFile(f, "r");
-                                     try {
-                                         final long end =
-                                             getLengthAndPositionAtCentralDirectory(a);
+                RandomAccessFile a = new RandomAccessFile(f, "r");
+                try {
+                    final long end = getLengthAndPositionAtCentralDirectory(a);
 
-                                         long cfhPos = a.getFilePointer();
-                                         // grab first entry, verify
-                                         // sizes are not 0xFFFFFFF
-                                         // and it has no 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
-                                                 20, 0,
-                                                 // version needed to extract
-                                                 20, 0,
-                                                 // GPB (EFS + Data Descriptor)
-                                                 8, 8,
-                                                 // method
-                                                 8, 0,
-                                             }, header);
-                                         // ignore timestamp
-                                         a.skipBytes(4);
-                                         byte[] crc = new byte[4];
-                                         a.readFully(crc);
-                                         assertArrayEquals(new byte[] {
-                                                 (byte) 0x9E, (byte) 0xCB,
-                                                 (byte) 0x79, (byte) 0x12,
-                                             }, crc);
-                                         // skip compressed size
-                                         a.skipBytes(4);
-                                         byte[] rest = new byte[23];
-                                         a.readFully(rest);
-                                         assertArrayEquals(new byte[] {
-                                                 // Original Size
-                                                 (byte) 0x40, (byte) 0x42,
-                                                 (byte) 0x0F, 0,
-                                                 // file name length
-                                                 1, 0,
-                                                 // extra field length
-                                                 0, 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);
+                    long cfhPos = a.getFilePointer();
+                    // grab first entry, verify sizes are not
+                    // 0xFFFFFFF and it has no 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
+                            20, 0,
+                            // version needed to extract
+                            20, 0,
+                            // GPB (EFS + Data Descriptor)
+                            8, 8,
+                            // method
+                            8, 0,
+                        }, header);
+                    // ignore timestamp
+                    a.skipBytes(4);
+                    byte[] crc = new byte[4];
+                    a.readFully(crc);
+                    assertArrayEquals(new byte[] {
+                            (byte) 0x9E, (byte) 0xCB,
+                            (byte) 0x79, (byte) 0x12,
+                        }, crc);
+                    // skip compressed size
+                    a.skipBytes(4);
+                    byte[] rest = new byte[23];
+                    a.readFully(rest);
+                    assertArrayEquals(new byte[] {
+                            // Original Size
+                            (byte) 0x40, (byte) 0x42,
+                            (byte) 0x0F, 0,
+                            // file name length
+                            1, 0,
+                            // extra field length
+                            0, 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);
 
-                                         // validate data descriptor
-                                         a.seek(cfhPos - 16);
-                                         byte[] dd = new byte[8];
-                                         a.readFully(dd);
-                                         assertArrayEquals(new byte[] {
-                                                 // sig
-                                                 (byte) 0x50, (byte) 0x4b, 7, 8,
-                                                 // CRC
-                                                 (byte) 0x9E, (byte) 0xCB,
-                                                 (byte) 0x79, (byte) 0x12,
-                                             }, dd);
-                                         // skip uncompressed size
-                                         a.skipBytes(4);
-                                         dd = new byte[4];
-                                         a.readFully(dd);
-                                         assertArrayEquals(new byte[] {
-                                                 // original size
-                                                 (byte) 0x40, (byte) 0x42,
-                                                 (byte) 0x0F, 0,
-                                             }, dd);
+                    // validate data descriptor
+                    a.seek(cfhPos - 16);
+                    byte[] dd = new byte[8];
+                    a.readFully(dd);
+                    assertArrayEquals(new byte[] {
+                            // sig
+                            (byte) 0x50, (byte) 0x4b, 7, 8,
+                            // CRC
+                            (byte) 0x9E, (byte) 0xCB, (byte) 0x79, (byte) 0x12,
+                        }, dd);
+                    // skip uncompressed size
+                    a.skipBytes(4);
+                    dd = new byte[4];
+                    a.readFully(dd);
+                    assertArrayEquals(new byte[] {
+                            // original size
+                            (byte) 0x40, (byte) 0x42, (byte) 0x0F, 0,
+                        }, dd);
 
-                                         // 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
-                                                 20, 0,
-                                                 // GPB (EFS + Data Descriptor)
-                                                 8, 8,
-                                                 // method
-                                                 8, 0,
-                                             }, header);
-                                         // ignore timestamp
-                                         a.skipBytes(4);
-                                         rest = new byte[17];
-                                         a.readFully(rest);
-                                         assertArrayEquals(new byte[] {
-                                                 // CRC
-                                                 0, 0, 0, 0,
-                                                 // Compressed Size
-                                                 0, 0, 0, 0,
-                                                 // Original Size
-                                                 0, 0, 0, 0,
-                                                 // file name length
-                                                 1, 0,
-                                                 // extra field length
-                                                 mode == Zip64Mode.Always
-                                                 ? (byte) 20 : 0,
-                                                 0,
-                                                 // file name
-                                                 (byte) '0'
-                                             }, rest);
+                    // 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
+                            20, 0,
+                            // GPB (EFS + Data Descriptor)
+                            8, 8,
+                            // method
+                            8, 0,
+                        }, header);
+                    // ignore timestamp
+                    a.skipBytes(4);
+                    rest = new byte[17];
+                    a.readFully(rest);
+                    assertArrayEquals(new byte[] {
+                            // CRC
+                            0, 0, 0, 0,
+                            // Compressed Size
+                            0, 0, 0, 0,
+                            // Original Size
+                            0, 0, 0, 0,
+                            // file name length
+                            1, 0,
+                            // extra field length
+                            mode == Zip64Mode.Always ? (byte) 20 : 0, 0,
+                            // file name
+                            (byte) '0'
+                        }, rest);
                     if (mode == Zip64Mode.Always) {
                         byte[] extra = new byte[20];
                         a.readFully(extra);
@@ -1400,22 +1398,14 @@ public class Zip64SupportTest {
                                 0, 0, 0, 0,
                             }, extra);
                     }
-
-                                     } finally {
-                                         a.close();
-                                     }
-                                 }
+                } finally {
+                    a.close();
+                }
+            }
         };
 
     }
 
-    /*
-     * One entry of length 1 million bytes, written with compression
-     * to a stream.
-     *
-     * Compression + Stream => sizes are set to 0 in LFH, real values
-     * are inside the data descriptor.  No ZIP64 extra field at all.
-     */
     @Test public void writeSmallDeflatedEntryKnownSizeToStream()
         throws Throwable {
         withTemporaryArchive("writeSmallDeflatedEntryKnownSizeToStream",
@@ -1432,18 +1422,18 @@ public class Zip64SupportTest {
                              false);
     }
 
+    private static ZipOutputTest writeSmallDeflatedEntryToFile(final boolean knownSize) {
+        return writeSmallDeflatedEntryToFile(knownSize, Zip64Mode.AsNeeded);
+    }
+
     /*
      * One entry of length 1 million bytes, written with compression
      * to a file.
      *
      * Writing to a file => sizes are stored directly inside the LFH.
      * No Data Descriptor at all.  Shouldn't contain any ZIP64 extra
-     * field if size was known.
+     * field if size was known and mode was not Always.
      */
-    private static ZipOutputTest writeSmallDeflatedEntryToFile(final boolean knownSize) {
-        return writeSmallDeflatedEntryToFile(knownSize, Zip64Mode.AsNeeded);
-    }
-
     private static ZipOutputTest
         writeSmallDeflatedEntryToFile(final boolean knownSize,
                                       final Zip64Mode mode) {



Mime
View raw message