Repository: commons-compress
Updated Branches:
  refs/heads/master 318de9ae8 -> a1d6b33f5


COMPRESS-351 Testcase


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/a1d6b33f
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/a1d6b33f
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/a1d6b33f

Branch: refs/heads/master
Commit: a1d6b33f5f6c21f8f74a70edc3b05af42515e734
Parents: 318de9a
Author: Stefan Bodewig <bode...@apache.org>
Authored: Mon Apr 25 09:53:28 2016 +0200
Committer: Stefan Bodewig <bode...@apache.org>
Committed: Mon Apr 25 09:53:28 2016 +0200

----------------------------------------------------------------------
 .../zip/ZipArchiveInputStreamTest.java          |  26 ++++++++++++++++++-
 src/test/resources/COMPRESS-351.zip             | Bin 0 -> 36996 bytes
 2 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/a1d6b33f/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
index c0abdcc..33d0efc 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
@@ -22,12 +22,14 @@ import static 
org.apache.commons.compress.AbstractTestCase.getFile;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.BufferedInputStream;
+import java.io.EOFException;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
-import java.io.IOException;
 
 import org.apache.commons.compress.utils.IOUtils;
 import org.junit.Test;
@@ -171,6 +173,28 @@ public class ZipArchiveInputStreamTest {
         }
     }
 
+    /**
+     * Test case for
+     * <a href="https://issues.apache.org/jira/browse/COMPRESS-351";
+     * >COMPRESS-351</a>.
+     */
+    @Test
+    public void testMessageWithCorruptFileName() throws Exception {
+        final ZipArchiveInputStream in = new ZipArchiveInputStream(new 
FileInputStream(getFile("COMPRESS-351.zip")));
+        try {
+            ZipArchiveEntry ze = in.getNextZipEntry();
+            while (ze != null) {
+                ze = in.getNextZipEntry();
+            }
+            fail("expected EOFException");
+        } catch (EOFException ex) {
+            String m = ex.getMessage();
+            assertTrue(m.startsWith("Truncated ZIP entry: ?2016")); // the 
first character is not printable
+        } finally {
+            in.close();
+        }
+    }
+
     @Test
     public void testUnzipBZip2CompressedEntry() throws Exception {
         final ZipArchiveInputStream in = new ZipArchiveInputStream(new 
FileInputStream(getFile("bzip2-zip.zip")));

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/a1d6b33f/src/test/resources/COMPRESS-351.zip
----------------------------------------------------------------------
diff --git a/src/test/resources/COMPRESS-351.zip 
b/src/test/resources/COMPRESS-351.zip
new file mode 100644
index 0000000..9e4c331
Binary files /dev/null and b/src/test/resources/COMPRESS-351.zip differ

Reply via email to