Author: bodewig
Date: Sun Dec 15 14:03:43 2013
New Revision: 1551022

URL: http://svn.apache.org/r1551022
Log:
add a test for unshrinking support in ZipFile

Added:
    commons/proper/compress/trunk/src/test/resources/SHRUNK.ZIP   (with props)
Modified:
    commons/proper/compress/trunk/src/changes/changes.xml
    
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java

Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1551022&r1=1551021&r2=1551022&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sun Dec 15 14:03:43 
2013
@@ -60,6 +60,10 @@ The <action> type attribute can be add,u
               due-to="Damjan Jovanovic">
         Read-Only support for .Z compressed files.
       </action> 
+      <action type="add" date="2013-12-06" due-to="Damjan Jovanovic">
+        ZipFile now supports reading entries compressed using the
+        SHRINKING method.
+      </action> 
       <action issue="COMPRESS-245" type="fix" date="2013-12-06">
         TarArchiveInputStream could fail to read an archive completely.
       </action> 

Modified: 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java?rev=1551022&r1=1551021&r2=1551022&view=diff
==============================================================================
--- 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 (original)
+++ 
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
 Sun Dec 15 14:03:43 2013
@@ -19,8 +19,10 @@
 package org.apache.commons.compress.archivers.zip;
 
 import static org.apache.commons.compress.AbstractTestCase.getFile;
+import static org.junit.Assert.assertArrayEquals;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -32,6 +34,7 @@ import java.util.TreeMap;
 import java.util.zip.ZipEntry;
 
 import junit.framework.TestCase;
+import org.apache.commons.compress.utils.IOUtils;
 
 public class ZipFileTest extends TestCase {
     private ZipFile zf = null;
@@ -236,6 +239,26 @@ public class ZipFileTest extends TestCas
         assertEquals(26101, ze.getSize());
     }
 
+    public void testUnshrinking() throws Exception {
+        zf = new ZipFile(getFile("SHRUNK.ZIP"));
+        ZipArchiveEntry test = zf.getEntry("TEST1.XML");
+        FileInputStream original = new FileInputStream(getFile("test1.xml"));
+        try {
+            assertArrayEquals(IOUtils.toByteArray(original),
+                              IOUtils.toByteArray(zf.getInputStream(test)));
+        } finally {
+            original.close();
+        }
+        test = zf.getEntry("TEST2.XML");
+        original = new FileInputStream(getFile("test2.xml"));
+        try {
+            assertArrayEquals(IOUtils.toByteArray(original),
+                              IOUtils.toByteArray(zf.getInputStream(test)));
+        } finally {
+            original.close();
+        }
+    }
+
     /*
      * ordertest.zip has been handcrafted.
      *

Added: commons/proper/compress/trunk/src/test/resources/SHRUNK.ZIP
URL: 
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/SHRUNK.ZIP?rev=1551022&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/proper/compress/trunk/src/test/resources/SHRUNK.ZIP
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to