commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject commons-compress git commit: Tests for [COMPRESS-359] Pack200 is broken.
Date Fri, 24 Jun 2016 16:46:39 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/master 9e6f0b398 -> 6c8345bff


Tests for [COMPRESS-359] Pack200 is broken.

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

Branch: refs/heads/master
Commit: 6c8345bff9b68598903a05f702ec15e969478cb9
Parents: 9e6f0b3
Author: Gary Gregory <ggregory@apache.org>
Authored: Fri Jun 24 09:46:35 2016 -0700
Committer: Gary Gregory <ggregory@apache.org>
Committed: Fri Jun 24 09:46:35 2016 -0700

----------------------------------------------------------------------
 .../CompressorStreamFactoryRoundtripTest.java   | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6c8345bf/src/test/java/org/apache/commons/compress/compressors/CompressorStreamFactoryRoundtripTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/compressors/CompressorStreamFactoryRoundtripTest.java
b/src/test/java/org/apache/commons/compress/compressors/CompressorStreamFactoryRoundtripTest.java
new file mode 100644
index 0000000..3ecb4c5
--- /dev/null
+++ b/src/test/java/org/apache/commons/compress/compressors/CompressorStreamFactoryRoundtripTest.java
@@ -0,0 +1,57 @@
+package org.apache.commons.compress.compressors;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.apache.commons.compress.utils.IOUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class CompressorStreamFactoryRoundtripTest {
+
+    @Parameters(name = "{0}")
+    public static String[] data() {
+        return new String[] { //
+                CompressorStreamFactory.BZIP2, //
+                CompressorStreamFactory.DEFLATE, //
+                CompressorStreamFactory.GZIP, //
+                // CompressorStreamFactory.LZMA, // Not implemented yet
+                // CompressorStreamFactory.PACK200, // Bug
+                // CompressorStreamFactory.SNAPPY_FRAMED, // Not implemented yet
+                // CompressorStreamFactory.SNAPPY_RAW, // Not implemented yet
+                CompressorStreamFactory.XZ, //
+                // CompressorStreamFactory.Z, // Not implemented yet
+        };
+    }
+
+    private final String compressorName;
+
+    public CompressorStreamFactoryRoundtripTest(final String compressorName) {
+        this.compressorName = compressorName;
+    }
+
+    @Test
+    public void testCompressorStreamFactoryRoundtrip() throws Exception {
+        final CompressorStreamFactory factory = new CompressorStreamFactory();
+        final ByteArrayOutputStream compressedOs = new ByteArrayOutputStream();
+        final CompressorOutputStream compressorOutputStream = factory.createCompressorOutputStream(compressorName,
+                compressedOs);
+        final String fixture = "The quick brown fox jumps over the lazy dog";
+        compressorOutputStream.write(fixture.getBytes("UTF-8"));
+        compressorOutputStream.flush();
+        compressorOutputStream.close();
+        final ByteArrayInputStream is = new ByteArrayInputStream(compressedOs.toByteArray());
+        final CompressorInputStream compressorInputStream = factory.createCompressorInputStream(compressorName,
is);
+        final ByteArrayOutputStream decompressedOs = new ByteArrayOutputStream();
+        IOUtils.copy(compressorInputStream, decompressedOs);
+        compressorInputStream.close();
+        decompressedOs.flush();
+        decompressedOs.close();
+        Assert.assertEquals(fixture, decompressedOs.toString("UTF-8"));
+    }
+
+}


Mime
View raw message