jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1133340 - in /jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk: ConcurrentWriteTest.java DataStoreTest.java HelloWorld.java
Date Wed, 08 Jun 2011 10:55:03 GMT
Author: thomasm
Date: Wed Jun  8 10:55:02 2011
New Revision: 1133340

URL: http://svn.apache.org/viewvc?rev=1133340&view=rev
Log:
Use the factory instead of the implementation (simplifies testing multiple implementations)

Modified:
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DataStoreTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java?rev=1133340&r1=1133339&r2=1133340&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/ConcurrentWriteTest.java
Wed Jun  8 10:55:02 2011
@@ -16,24 +16,26 @@
  */
 package org.apache.jackrabbit.mk;
 
+import java.util.Random;
 import junit.framework.TestCase;
 import org.apache.jackrabbit.mk.api.MicroKernel;
 
-import java.util.Random;
-
 public class ConcurrentWriteTest extends TestCase {
 
+    private static final String URL = "fs:{homeDir};clean";
+    // private static final String URL = "mem:";
+
     private static final int NUM_THREADS = 10;
     private static final int NUM_CHILDNODES = 100;
 
     private MicroKernel mk;
 
     public void setUp() throws Exception {
-        mk = new MicroKernelImpl(System.getProperty("homeDir", "."));
+        mk = MicroKernelFactory.getInstance(URL);
     }
 
     public void tearDown() throws InterruptedException {
-        ((MicroKernelImpl) mk).dispose();
+        mk.dispose();
     }
 
     /**
@@ -41,6 +43,11 @@ public class ConcurrentWriteTest extends
      */
     public void testConcurrentWriting() throws Exception {
 
+        Profiler prof = new Profiler();
+        prof.depth = 8;
+        prof.interval = 1;
+	// prof.startCollecting();
+
         String head = mk.getHeadRevision();
         if (mk.nodeExists("/test", head)) {
             head = mk.commit("/", "-\"test\" : \"\"", head);
@@ -85,6 +92,8 @@ public class ConcurrentWriteTest extends
         //System.out.println(journal);
         System.out.println();
 
+        // System.out.println(prof.getTop(5));
+
     }
 
     class TestThread extends Thread {

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DataStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DataStoreTest.java?rev=1133340&r1=1133339&r2=1133340&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DataStoreTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/DataStoreTest.java
Wed Jun  8 10:55:02 2011
@@ -18,7 +18,7 @@ package org.apache.jackrabbit.mk;
 
 import java.io.ByteArrayInputStream;
 import junit.framework.TestCase;
-import org.apache.jackrabbit.mk.mem.MemoryKernelImpl;
+import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.util.MicroKernelInputStream;
 
 /**
@@ -26,16 +26,17 @@ import org.apache.jackrabbit.mk.util.Mic
  */
 public class DataStoreTest extends TestCase {
 
-    // private MicroKernelImpl mk;
-    private MemoryKernelImpl mk;
+    // private static final String URL = "fs:{homeDir};clean";
+    private static final String URL = "mem:";
+
+    private MicroKernel mk;
 
     public void setUp() throws Exception {
-        // mk = new MicroKernelImpl(System.getProperty("homeDir", "."));
-        mk = new MemoryKernelImpl();
+        mk = MicroKernelFactory.getInstance(URL);
     }
 
     public void tearDown() throws InterruptedException {
-        // mk.dispose();
+        mk.dispose();
     }
 
     public void test() {

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java?rev=1133340&r1=1133339&r2=1133340&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/HelloWorld.java
Wed Jun  8 10:55:02 2011
@@ -16,8 +16,7 @@
  */
 package org.apache.jackrabbit.mk;
 
-import java.io.File;
-import org.apache.jackrabbit.mk.mem.MemoryKernelImpl;
+import org.apache.jackrabbit.mk.api.MicroKernel;
 
 /**
  * A simple hello world app.
@@ -25,11 +24,13 @@ import org.apache.jackrabbit.mk.mem.Memo
 public class HelloWorld {
 
     public static void main(String... args) {
-        String dir = ".";
-        new File(dir, ".mk/db/revs.h2.db").delete();
+        test("mem:");
+        // test("fs:{homeDir};clean");
+    }
+
+    private static void test(String url) {
 
-        // MicroKernelImpl mk = new MicroKernelImpl(System.getProperty("homeDir", "."));
-        MemoryKernelImpl mk = new MemoryKernelImpl();
+        MicroKernel mk = MicroKernelFactory.getInstance(url);
 
         String head = mk.getHeadRevision();
 
@@ -49,10 +50,10 @@ public class HelloWorld {
 
         System.out.println(s);
 
-        head = mk.commit("/", "-\"test\"", head);
+        head = mk.commit("/", "- \"test\"", head);
         s = mk.getNodes("/", 0, head);
         System.out.println(s);
 
-        // mk.dispose();
+        mk.dispose();
     }
 }



Mime
View raw message