jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1133774 - /jackrabbit/sandbox/spi2microkernel/src/test/java/org/apache/jackrabbit/spi2microkernel/MicrokernelTest.java
Date Thu, 09 Jun 2011 10:21:46 GMT
Author: thomasm
Date: Thu Jun  9 10:21:46 2011
New Revision: 1133774

URL: http://svn.apache.org/viewvc?rev=1133774&view=rev
Log:
Enabled and fix tests.

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=1133774&r1=1133773&r2=1133774&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 Jun  9 10:21:46 2011
@@ -19,25 +19,24 @@
 
 package org.apache.jackrabbit.spi2microkernel;
 
-import org.apache.jackrabbit.mk.MicroKernelImpl;
+import org.apache.jackrabbit.mk.MicroKernelFactory;
 import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.ParseException;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
-import java.io.File;
-import java.lang.reflect.Array;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 public class MicrokernelTest {
-    private static final File REPO_HOME_DIR = new File("target/micro-kernel-test/repository");
 
-    private MicroKernelImpl microkernel;
+    private static final String URL = "fs:target/repository-test/repository;clean";
+    // private static final String URL = "mem:test";
+
+    private MicroKernel microkernel;
 
     @Before
     public void setup() {
@@ -45,15 +44,14 @@ public class MicrokernelTest {
         String head = mk.getHeadRevision();
 
         if (!mk.nodeExists("/test", head)) {
-            mk.commit("/", "+test : {" +
+            mk.commit("/", "+\"test\" : {" +
                 "\"stringProp\":\"stringVal\"," +
                 "\"intProp\":42," +
                 "\"floatProp\":42.2," +
                 "\"multiIntProp\":[1,2,3]} ", head);
         }
     }
-    
-    @Ignore  // todo fix in microkernel
+
     @Test
     public void missingName() {
         MicroKernel mk = getMicroKernel();
@@ -69,7 +67,7 @@ public class MicrokernelTest {
         MicroKernel mk = getMicroKernel();
         String head = mk.getHeadRevision();
 
-        head = mk.commit("/", "+foo : {} \n+foo/bar : {}", head);
+        head = mk.commit("/", "+\"foo\" : {} \n+\"foo/bar\" : {}", head);
         assertTrue(mk.nodeExists("/foo", head));
         assertTrue(mk.nodeExists("/foo/bar", head));
     }
@@ -79,9 +77,11 @@ public class MicrokernelTest {
         MicroKernel mk = getMicroKernel();
         String head = mk.getHeadRevision();
 
-        head = mk.commit("/", "+fuu : {} \n^fuu/bar : 42", head);
+        head = mk.commit("/",
+                "+\"fuu\" : {} \n" +
+                "^\"fuu/bar\" : 42", head);
         String n = mk.getNodes("/fuu", 2, head);
-        assertEquals("{\":name\":\"fuu\",\"bar\":\"42\",\":childNodeCount\":0}", n);
+        assertEquals("{\":name\":\"fuu\",\"bar\":42,\":childNodeCount\":0}", n);
     }
 
     @Test
@@ -92,7 +92,7 @@ public class MicrokernelTest {
         long millis = System.currentTimeMillis();
         String node1 = "n1_" + millis;
         String node2 = "n2_" + millis;
-        head = mk.commit("/", '+' + node1 + " : {} \r+" + node2 + " : {}\n", head);
+        head = mk.commit("/", "+\"" + node1 + "\" : {} \r+\"" + node2 + "\" : {}\n", head);
         assertTrue(mk.nodeExists('/' + node1, head));
         assertTrue(mk.nodeExists('/' + node2, head));
     }
@@ -105,19 +105,19 @@ public class MicrokernelTest {
         String node = "n_" + System.currentTimeMillis();
 
         head = mk.commit("/",
-                '+' + node + " : {} \r" +
-                '+' + node + "/child1 : {} \r" +
-                '+' + node + "/child2 : {} \r" +
-                '+' + node + "/child1/grandchild11 : {} \r" +
-                '^' + node + "/prop1 : 41\r" +
-                '^' + node + "/child1/prop2 : 42\r" +
-                '^' + node + "/child1/grandchild11/prop3 : 43",
+                "+\"" + node + "\" : {} \r" +
+                "+\"" + node + "/child1\" : {} \r" +
+                "+\"" + node + "/child2\" : {} \r" +
+                "+\"" + node + "/child1/grandchild11\" : {} \r" +
+                "^\"" + node + "/prop1\" : 41\r" +
+                "^\"" + node + "/child1/prop2\" : 42\r" +
+                "^\"" + node + "/child1/grandchild11/prop3\" : 43",
                 head);
 
         String json = mk.getNodes('/' + node, 2, head);
-        assertEquals("{\":name\":\"" + node + "\",\"prop1\":\"41\",\":childNodeCount\":2,"
+
-                "\"child1\":{\":name\":\"child1\",\"prop2\":\"42\",\":childNodeCount\":1,"
+
-                "\"grandchild11\":{\":name\":\"grandchild11\",\"prop3\":\"43\",\":childNodeCount\":0}},"
+
+        assertEquals("{\":name\":\"" + node + "\",\"prop1\":41,\":childNodeCount\":2," +
+                "\"child1\":{\":name\":\"child1\",\"prop2\":42,\":childNodeCount\":1," +
+                "\"grandchild11\":{\":name\":\"grandchild11\",\"prop3\":43,\":childNodeCount\":0}},"
+
                 "\"child2\":{\":name\":\"child2\",\":childNodeCount\":0}}", json);
     }
 
@@ -160,7 +160,6 @@ public class MicrokernelTest {
         assertEquals("stringVal", stringProp);
     }
 
-    @Ignore  // todo fix in microkernel
     @Test
     public void getIntProperty() throws ParseException {
         MicroKernel mk = getMicroKernel();
@@ -170,10 +169,9 @@ public class MicrokernelTest {
         JSONObject result = (JSONObject) new JSONParser().parse(json);
         Object intProp = result.get("intProp");
         assertTrue(intProp instanceof Long);
-        assertEquals(42, intProp);
+        assertEquals(42L, intProp);
     }
 
-    @Ignore  // todo fix in microkernel
     @Test
     public void getFloatProperty() throws ParseException {
         MicroKernel mk = getMicroKernel();
@@ -186,7 +184,6 @@ public class MicrokernelTest {
         assertEquals(42.2, floatProp);
     }
 
-    @Ignore  // todo fix in microkernel
     @Test
     public void getMultiIntProperty() throws ParseException {
         MicroKernel mk = getMicroKernel();
@@ -195,16 +192,16 @@ public class MicrokernelTest {
         String json = mk.getNodes("/test", 2, head);
         JSONObject result = (JSONObject) new JSONParser().parse(json);
         Object multiIntProp = result.get("multiIntProp");
-        assertTrue(multiIntProp instanceof Array);
+        assertTrue(multiIntProp instanceof JSONArray);
     }
 
     //------------------------------------------< private >---
 
     private MicroKernel getMicroKernel() {
         if (microkernel == null) {
-            microkernel = new MicroKernelImpl(REPO_HOME_DIR.getAbsolutePath());
+            microkernel = MicroKernelFactory.getInstance(URL);
         }
-        return microkernel; 
+        return microkernel;
     }
 
 }



Mime
View raw message