jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1291720 - /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Date Tue, 21 Feb 2012 11:43:43 GMT
Author: mduerig
Date: Tue Feb 21 11:43:42 2012
New Revision: 1291720

URL: http://svn.apache.org/viewvc?rev=1291720&view=rev
Log:
largeNodeList

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java?rev=1291720&r1=1291719&r2=1291720&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/RepositoryTest.java
Tue Feb 21 11:43:42 2012
@@ -86,7 +86,7 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 public class RepositoryTest {
-    private static final boolean USE_MEM_KERNEL = false;
+    private static final boolean USE_MEM_KERNEL = true;
 
     private static final String BASE_URL = USE_MEM_KERNEL
         ? "mem:fs:target/temp"
@@ -175,30 +175,35 @@ public class RepositoryTest {
     @Test
     @Ignore("WIP")
     public void largeNodeList() throws RepositoryException {
-        if (!USE_MEM_KERNEL) {
-            return;
-        }
-
         Node node = getNode(testPath);
-        
-        for (int i = 0; i < 1000; i++) {
-            for (int j = 0; j < 100; j++) {
-                node.addNode("(" + i + ',' + j + ')');
+
+        double sum = 0.0;
+        long t = System.currentTimeMillis();
+        for (int i = 0; i < 1000000; i++) {
+            node.addNode("node" + i);
+            if (i % 1000 == 0) {
+                node.getSession().save();
+                long dt = System.currentTimeMillis() - t;
+                sum += dt;
+                // number,time,average
+                System.out.println(i + "," + dt + "," + sum/(i + 1));
+                t = System.currentTimeMillis();
             }
-            node.getSession().save();
         }
         
-        Session session = getRepository().login();
-        try {
-            Node node2 = session.getNode(testPath);
-            NodeIterator childNodes = node2.getNodes();
-            while (childNodes.hasNext()) {
-                Node child = childNodes.nextNode();
-            }
-        }
-        finally {
-            session.logout();
-        }
+//        t = System.currentTimeMillis();
+//        Session session = getRepository().login();
+//        try {
+//            Node node2 = session.getNode(testPath);
+//            NodeIterator childNodes = node2.getNodes();
+//            while (childNodes.hasNext()) {
+//                Node child = childNodes.nextNode();
+//            }
+//        }
+//        finally {
+//            System.out.println(System.currentTimeMillis() - t);
+//            session.logout();
+//        }
     }
 
     @Test
@@ -727,6 +732,34 @@ public class RepositoryTest {
         Binary bin = getSession().getValueFactory().createBinary(is);
         addProperty(parentNode, "binary", getSession().getValueFactory().createValue(bin));
     }
+    
+    @Test
+    public void addFileNode() throws RepositoryException, IOException {
+        Node parentNode = getNode(testPath);
+        Node file = parentNode.addNode("file", "nt:file");
+        Node content = file.addNode("jcr:content", "nt:resource");
+        InputStream is = new ByteArrayInputStream("this is a test".getBytes());
+        Binary bin = getSession().getValueFactory().createBinary(is);
+        content.setProperty("jcr:data", bin);
+        parentNode.getSession().save();
+
+        Session session = getRepository().login();
+        parentNode = session.getNode(testPath);
+        file = parentNode.getNode("file");
+        content = file.getNode("jcr:content");
+        Property data = content.getProperty("jcr:data");
+
+        InputStream inStream = data.getBinary().getStream();
+        StringBuilder sb = new StringBuilder();
+        int c;
+        while ((c = inStream.read()) != -1) {
+            sb.append((char) c);
+        }
+
+        assertEquals("this is a test", sb.toString());
+    }
+
+
 
     @Test
     public void addSmallBinaryProperty() throws RepositoryException, IOException {



Mime
View raw message