commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1548930 - /commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/compressors/FramedSnappyTestCase.java
Date Sat, 07 Dec 2013 15:27:58 GMT
Author: bodewig
Date: Sat Dec  7 15:27:57 2013
New Revision: 1548930

URL: http://svn.apache.org/r1548930
Log:
COMPRESS-147 test for available method

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=1548930&r1=1548929&r2=1548930&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
Sat Dec  7 15:27:57 2013
@@ -152,6 +152,25 @@ public final class FramedSnappyTestCase
             }, out.toByteArray());
     }
 
+    public void testAvailable() throws Exception {
+        final FileInputStream isSz = new FileInputStream(getFile("mixed.txt.sz"));
+        try {
+            CompressorInputStream in = new FramedSnappyCompressorInputStream(isSz);
+            assertEquals(0, in.available()); // no chunk read so far
+            assertEquals('1', in.read());
+            assertEquals(3, in.available()); // remainder of first uncompressed block
+            assertEquals(3, in.read(new byte[5], 0, 3));
+            assertEquals('5', in.read());
+            assertEquals(4, in.available()); // remainder of literal
+            assertEquals(4, in.read(new byte[5], 0, 4));
+            assertEquals('5', in.read());
+            assertEquals(19, in.available()); // remainder of copy
+            in.close();
+        } finally {
+            isSz.close();
+        }
+    }
+
     private void testUnarchive(StreamWrapper<CompressorInputStream> wrapper) throws
Exception {
         final File input = getFile("bla.tar.sz");
         final File output = new File(dir, "bla.tar");



Mime
View raw message