Author: mduerig
Date: Mon May  8 10:37:24 2017
New Revision: 1794320

URL: http://svn.apache.org/viewvc?rev=1794320&view=rev
Log:
OAK-6173: Add unit test coverage for IOUtils.copy
Added test
Credits to Matt Ryan for the patch.

Modified:
    
jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/IOUtilsTest.java

Modified: 
jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/IOUtilsTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/IOUtilsTest.java?rev=1794320&r1=1794319&r2=1794320&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/IOUtilsTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/IOUtilsTest.java
 Mon May  8 10:37:24 2017
@@ -274,6 +274,18 @@ public class IOUtilsTest extends TestCas
         assertEquals(1L, IOUtils.nextPowerOf2(Integer.MIN_VALUE));
     }
 
+    public void testCopyStream() throws IOException {
+        final Random r = new Random(1);
+        for (int length : Lists.newArrayList(0, 1, 1000, 4096, 4097, 
1024*1024)) {
+            byte[] inData = new byte[length];
+            r.nextBytes(inData);
+            ByteArrayInputStream in = new ByteArrayInputStream(inData);
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            IOUtils.copy(in, out);
+            assertEquals(inData, out.toByteArray());
+        }
+    }
+
     private static void testVarInt(int x, int expectedLen) throws IOException {
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         IOUtils.writeVarInt(out, x);


Reply via email to