commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1546791 - in /commons/proper/compress/trunk/src/test: java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java resources/lorem-ipsum.txt.gz resources/lorem-ipsum.txt.sz
Date Sun, 01 Dec 2013 08:12:35 GMT
Author: bodewig
Date: Sun Dec  1 08:12:35 2013
New Revision: 1546791

URL: http://svn.apache.org/r1546791
Log:
COMPRESS-147 test file big enough to make the Snappy buffers slide

Added:
    commons/proper/compress/trunk/src/test/resources/lorem-ipsum.txt.gz   (with props)
    commons/proper/compress/trunk/src/test/resources/lorem-ipsum.txt.sz   (with props)
Modified:
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java?rev=1546791&r1=1546790&r2=1546791&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java
Sun Dec  1 08:12:35 2013
@@ -27,6 +27,7 @@ import java.io.InputStream;
 import java.util.Arrays;
 
 import org.apache.commons.compress.AbstractTestCase;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
 import org.apache.commons.compress.compressors.snappy.FramedSnappyCompressorInputStream;
 import org.apache.commons.compress.utils.IOUtils;
 
@@ -74,6 +75,58 @@ public final class FramedSnappyTestCase
         });
     }
 
+    /**
+     * Something big enough to make buffers slide.
+     */
+    public void testLoremIpsum() throws Exception {
+        final FileInputStream isSz = new FileInputStream(getFile("lorem-ipsum.txt.sz"));
+        final File outputSz = new File(dir, "lorem-ipsum.1");
+        final File outputGz = new File(dir, "lorem-ipsum.2");
+        try {
+            CompressorInputStream in = new FramedSnappyCompressorInputStream(isSz);
+            FileOutputStream out = null;
+            try {
+                out = new FileOutputStream(outputSz);
+                IOUtils.copy(in, out);
+            } finally {
+                if (out != null) {
+                    out.close();
+                }
+                in.close();
+            }
+            final FileInputStream isGz = new FileInputStream(getFile("lorem-ipsum.txt.gz"));
+            try {
+                in = new GzipCompressorInputStream(isGz);
+                try {
+                    out = new FileOutputStream(outputGz);
+                    IOUtils.copy(in, out);
+                } finally {
+                    if (out != null) {
+                        out.close();
+                    }
+                    in.close();
+                }
+            } finally {
+                isGz.close();
+            }
+        } finally {
+            isSz.close();
+        }
+
+        final FileInputStream sz = new FileInputStream(outputSz);
+        try {
+            FileInputStream gz = new FileInputStream(outputGz);
+            try {
+                assertTrue(Arrays.equals(IOUtils.toByteArray(sz),
+                                         IOUtils.toByteArray(gz)));
+            } finally {
+                gz.close();
+            }
+        } finally {
+            sz.close();
+        }
+    }
+
     private void testUnarchive(StreamWrapper<CompressorInputStream> wrapper) throws
Exception {
         final File input = getFile("bla.tar.sz");
         final File output = new File(dir, "bla.tar");

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

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

Added: commons/proper/compress/trunk/src/test/resources/lorem-ipsum.txt.sz
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/lorem-ipsum.txt.sz?rev=1546791&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/proper/compress/trunk/src/test/resources/lorem-ipsum.txt.sz
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message