jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1242916 - /jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/IOUtilsTest.java
Date Fri, 10 Feb 2012 20:43:41 GMT
Author: stefan
Date: Fri Feb 10 20:43:41 2012
New Revision: 1242916

URL: http://svn.apache.org/viewvc?rev=1242916&view=rev
Log:
serialize byte[] values

Modified:
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/IOUtilsTest.java

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/IOUtilsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/IOUtilsTest.java?rev=1242916&r1=1242915&r2=1242916&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/IOUtilsTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/util/IOUtilsTest.java
Fri Feb 10 20:43:41 2012
@@ -24,6 +24,7 @@ import java.io.EOFException;
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Arrays;
 import java.util.Random;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -115,6 +116,20 @@ public class IOUtilsTest extends TestCas
         }
     }
 
+    public void testBytesReadWrite() throws IOException {
+        final Random r = new Random();
+        int iterations = 1000;
+        while (iterations-- > 0) {
+            int n = Math.abs(r.nextInt()) % 0x40000;
+            byte[] buf = new byte[n];
+            r.nextBytes(buf);
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            IOUtils.writeBytes(out, buf);
+            byte[] buf1 = IOUtils.readBytes(new ByteArrayInputStream(out.toByteArray()));
+            assertEquals(buf, buf1);
+        }
+    }
+
     public void testVarInt() throws IOException {
         testVarInt(0, 1);
         testVarInt(0x7f, 1);



Mime
View raw message