jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1174088 - in /jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk: HelloWorld.java MoveNodeTest.java
Date Thu, 22 Sep 2011 12:32:09 GMT
Author: thomasm
Date: Thu Sep 22 12:32:08 2011
New Revision: 1174088

URL: http://svn.apache.org/viewvc?rev=1174088&view=rev
Log:
Test case for move&set.

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

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=1174088&r1=1174087&r2=1174088&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
Thu Sep 22 12:32:08 2011
@@ -17,65 +17,36 @@
 package org.apache.jackrabbit.mk;
 
 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 java.util.ArrayList;
-
 /**
  * A simple hello world app.
  */
 public class HelloWorld {
 
     public static void main(String... args) throws ParseException {
+        test("fs:{homeDir};clean");
         test("mem:");
-        // test("fs:{homeDir};clean");
     }
 
     private static void test(String url) throws ParseException {
-
         MicroKernel mk = MicroKernelFactory.getInstance(url);
-
+        System.out.println(url);
         String head = mk.getHeadRevision();
-
-        System.out.println("head: " + head);
-        // head: b452fb882383cce6fdd123a78b5f1070728e2a0e
-
-        if (mk.nodeExists("/test", head)) {
-            // head = mk.commit(null, "- \"/test\"", head);
-            head = mk.commit("/", "-\"test\"", head, null);
-        }
-
-        head = mk.commit("/", "+\"test\" : {\"x\":\"1\"}", head, null);
-        head = mk.commit("/", "-\"test\"", head, null);
-        head = mk.commit("/", "+\"test\" : {\"x\":\"1\"}", head, null);
-        head = mk.commit("/", "-\"test\" +\"test\" : {\"x\":\"2\"}", head, null);
-
-        String revs = mk.getRevisions(0, 100);
-
-        ArrayList<String> revList = new ArrayList<String>();
-        JSONParser p = new JSONParser();
-        JSONArray a = (JSONArray) p.parse(revs);
-        for (int i = 0; i < a.size(); i++) {
-            JSONObject o = (JSONObject) a.get(i);
-            revList.add(o.get("id").toString());
+        head = mk.commit("/", "+ \"hello\" : {}", head, null);
+        String move = "> \"hello\": \"world\" ";
+        String set = "^ \"world/x\": 1 ";
+        try {
+            head = mk.commit("/", move + set, head, null);
+            System.out.println("move & set worked");
+        } catch (Exception e) {
+            System.out.println("move & set didn't work:");
+            e.printStackTrace(System.out);
+            head = mk.commit("/", move, head, null);
+            head = mk.commit("/", set, head, null);
         }
-
-        String j;
-        j = mk.getJournal(revList.get(0), revList.get(revList.size() - 1));
-        System.out.println(j);
-        j = mk.getJournal(revList.get(0), revList.get(1));
-        System.out.println(j);
-        j = mk.getJournal(revList.get(1), revList.get(revList.size() - 1));
-        System.out.println(j);
-        j = mk.getJournal(revList.get(2), revList.get(revList.size() - 1));
-        System.out.println(j);
-
+        System.out.println();
         mk.dispose();
-
-        System.out.println("");
     }
 
 }

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java?rev=1174088&r1=1174087&r2=1174088&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/MoveNodeTest.java
Thu Sep 22 12:32:08 2011
@@ -148,6 +148,25 @@ public class MoveNodeTest extends MultiM
     }
 
     @Test
+    public void moveCombinedWithSet() {
+        if (url.startsWith("fs:")) {
+            return;
+        }
+
+        // move /test/b to /test_b
+        commit("/", "> \"test/b\": \"test_b\"");
+        Assert.assertEquals("{a,c}", getNode("/test"));
+        Assert.assertEquals("{}", getNode("/test_b"));
+        assertJournal("> \"/test/b\":\"/test_b\"");
+
+        // move /test/a to /test_a, combined with adding a property
+        commit("/", "> \"test/a\": \"test_a\" ^ \"test_a/x\": 1");
+        Assert.assertEquals("{c}", getNode("/test"));
+        Assert.assertEquals("{x:1}", getNode("/test_a"));
+        assertJournal("> \"/test/a\":\"/test_a\"\n+ \"/test_a/x\":1");
+    }
+
+    @Test
     public void moveBefore() {
         if (url.startsWith("fs:")) {
             return;



Mime
View raw message