jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1146642 - /jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
Date Thu, 14 Jul 2011 10:42:44 GMT
Author: mduerig
Date: Thu Jul 14 10:42:44 2011
New Revision: 1146642

URL: http://svn.apache.org/viewvc?rev=1146642&view=rev
Log:
spi2microkernel (WIP)
- data store test

Modified:
    jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java

Modified: jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java?rev=1146642&r1=1146641&r2=1146642&view=diff
==============================================================================
--- jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
(original)
+++ jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
Thu Jul 14 10:42:44 2011
@@ -32,6 +32,10 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -308,6 +312,35 @@ public class MicrokernelTest {
         tokenizer.read(JsopTokenizer.END);
     }
 
+    @Test
+    public void blobTest() {
+        MicroKernel mk = getMicroKernel();
+
+        InputStream is = new InputStream() {
+            int counter;
+
+            @Override
+            public int read() throws IOException {
+                return counter < 12345678
+                    ? counter++ & 255
+                    : -1;
+            }
+        };
+
+        String blobId = mk.write(new BufferedInputStream(is));
+
+        int pos = 0;
+        int count;
+        byte val = 0;
+        byte[] buf = new byte[65536];
+        while ((count = mk.read(blobId, pos, buf, 0, buf.length)) != -1) {
+            pos += count;
+            for (int c = 0; c < count; c++) {
+                assertEquals(val++, buf[c]);
+            }
+        }
+    }
+
     //------------------------------------------< private >---
 
     private MicroKernel getMicroKernel() {



Mime
View raw message