commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1203621 - in /commons/proper/compress/trunk/src/test: java/org/apache/commons/compress/compressors/ resources/
Date Fri, 18 Nov 2011 12:20:06 GMT
Author: bodewig
Date: Fri Nov 18 12:20:05 2011
New Revision: 1203621

URL: http://svn.apache.org/viewvc?rev=1203621&view=rev
Log:
testcases for compressors with concatenated streams.  COMPRESS-146 COMPRESS-154 COMPRESS156

Added:
    commons/proper/compress/trunk/src/test/resources/multiple.bz2   (with props)
    commons/proper/compress/trunk/src/test/resources/multiple.gz   (with props)
    commons/proper/compress/trunk/src/test/resources/multiple.xz   (with props)
Modified:
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java?rev=1203621&r1=1203620&r2=1203621&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/BZip2TestCase.java
Fri Nov 18 12:20:05 2011
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.commons.compress.AbstractTestCase;
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
 import org.apache.commons.compress.utils.IOUtils;
 
 public final class BZip2TestCase extends AbstractTestCase {
@@ -68,4 +69,39 @@ public final class BZip2TestCase extends
         os.close();
     }
 
+    public void testConcatenatedStreamsReadFirstOnly() throws Exception {
+        final File input = getFile("multiple.bz2");
+        final InputStream is = new FileInputStream(input);
+        try {
+            final CompressorInputStream in = new CompressorStreamFactory()
+                .createCompressorInputStream("bzip2", is);
+            try {
+                assertEquals('a', in.read());
+                assertEquals(-1, in.read());
+            } finally {
+                in.close();
+            }
+        } finally {
+            is.close();
+        }
+    }
+
+    public void testConcatenatedStreamsReadFully() throws Exception {
+        final File input = getFile("multiple.bz2");
+        final InputStream is = new FileInputStream(input);
+        try {
+            final CompressorInputStream in =
+                new BZip2CompressorInputStream(is, true);
+            try {
+                assertEquals('a', in.read());
+                assertEquals('b', in.read());
+                assertEquals(0, in.available());
+                assertEquals(-1, in.read());
+            } finally {
+                in.close();
+            }
+        } finally {
+            is.close();
+        }
+    }
 }

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java?rev=1203621&r1=1203620&r2=1203621&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/GZipTestCase.java
Fri Nov 18 12:20:05 2011
@@ -28,6 +28,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.commons.compress.AbstractTestCase;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.commons.compress.utils.IOUtils;
 
 public final class GZipTestCase extends AbstractTestCase {
@@ -71,6 +72,42 @@ public final class GZipTestCase extends 
         }
     }
 
+    public void testConcatenatedStreamsReadFirstOnly() throws Exception {
+        final File input = getFile("multiple.gz");
+        final InputStream is = new FileInputStream(input);
+        try {
+            final CompressorInputStream in = new CompressorStreamFactory()
+                .createCompressorInputStream("gz", is);
+            try {
+                assertEquals('a', in.read());
+                assertEquals(-1, in.read());
+            } finally {
+                in.close();
+            }
+        } finally {
+            is.close();
+        }
+    }
+
+    public void testConcatenatedStreamsReadFully() throws Exception {
+        final File input = getFile("multiple.gz");
+        final InputStream is = new FileInputStream(input);
+        try {
+            final CompressorInputStream in =
+                new GzipCompressorInputStream(is, true);
+            try {
+                assertEquals('a', in.read());
+                assertEquals('b', in.read());
+                assertEquals(0, in.available());
+                assertEquals(-1, in.read());
+            } finally {
+                in.close();
+            }
+        } finally {
+            is.close();
+        }
+    }
+
     /**
      * @see "https://issues.apache.org/jira/browse/COMPRESS-84"
      */

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java?rev=1203621&r1=1203620&r2=1203621&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/XZTestCase.java
Fri Nov 18 12:20:05 2011
@@ -25,6 +25,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.commons.compress.AbstractTestCase;
+import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
 import org.apache.commons.compress.utils.IOUtils;
 
 public final class XZTestCase extends AbstractTestCase {
@@ -68,4 +69,39 @@ public final class XZTestCase extends Ab
         }
     }
 
+    public void testConcatenatedStreamsReadFirstOnly() throws Exception {
+        final File input = getFile("multiple.xz");
+        final InputStream is = new FileInputStream(input);
+        try {
+            final CompressorInputStream in = new CompressorStreamFactory()
+                .createCompressorInputStream("xz", is);
+            try {
+                assertEquals('a', in.read());
+                assertEquals(-1, in.read());
+            } finally {
+                in.close();
+            }
+        } finally {
+            is.close();
+        }
+    }
+
+    public void testConcatenatedStreamsReadFully() throws Exception {
+        final File input = getFile("multiple.xz");
+        final InputStream is = new FileInputStream(input);
+        try {
+            final CompressorInputStream in =
+                new XZCompressorInputStream(is, true);
+            try {
+                assertEquals('a', in.read());
+                assertEquals('b', in.read());
+                assertEquals(0, in.available());
+                assertEquals(-1, in.read());
+            } finally {
+                in.close();
+            }
+        } finally {
+            is.close();
+        }
+    }
 }

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

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

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

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

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

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



Mime
View raw message