jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1242753 - in /jackrabbit/sandbox/jackrabbit-microkernel/src: main/java/org/apache/jackrabbit/state/ChangeLog.java test/java/org/apache/jackrabbit/state/ChangeLogFuzzTest.java test/java/org/apache/jackrabbit/state/ChangeLogTest.java
Date Fri, 10 Feb 2012 12:29:31 GMT
Author: mduerig
Date: Fri Feb 10 12:29:30 2012
New Revision: 1242753

URL: http://svn.apache.org/viewvc?rev=1242753&view=rev
Log:
Microkernel based prototype of JCR implementation (WIP)
- clear() method for change log
- allow null for setProperty

Modified:
    jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeLog.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogFuzzTest.java
    jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeLog.java?rev=1242753&r1=1242752&r2=1242753&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeLog.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/main/java/org/apache/jackrabbit/state/ChangeLog.java
Fri Feb 10 12:29:30 2012
@@ -43,6 +43,13 @@ public class ChangeLog {
     private final List<Operation> operations = new ArrayList<Operation>();
 
     /**
+     * Clear this change log to its empty state
+     */
+    public void clear() {
+        operations.clear();
+    }
+
+    /**
      * Add a add node operation to this change log
      * @param path  path of the added node
      */
@@ -74,6 +81,9 @@ public class ChangeLog {
      * @param value  value of the property
      */
     public void setProperty(Path parent, String name, JsonAtom value) {
+        if (value == null) {
+            value = JsonAtom.NULL;
+        }
         addOperation(Operation.setProperty(parent, name, value));
     }
 

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogFuzzTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogFuzzTest.java?rev=1242753&r1=1242752&r2=1242753&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogFuzzTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogFuzzTest.java
Fri Feb 10 12:29:30 2012
@@ -456,7 +456,7 @@ public class ChangeLogFuzzTest {
 
     private static class ChangeLogConsolidator {
         private final MicroKernel microkernel;
-        private ChangeLog changeLog = new ChangeLog();
+        private final ChangeLog changeLog = new ChangeLog();
 
         public ChangeLogConsolidator(MicroKernel microkernel) {
             this.microkernel = microkernel;
@@ -482,7 +482,7 @@ public class ChangeLogFuzzTest {
             String jsop = changeLog.toJsop();
             log.info("jsop = {}", jsop);
             microkernel.commit("", jsop, microkernel.getHeadRevision(), "");
-            changeLog = new ChangeLog();
+            changeLog.clear();
         }
     }
 }

Modified: jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java?rev=1242753&r1=1242752&r2=1242753&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-microkernel/src/test/java/org/apache/jackrabbit/state/ChangeLogTest.java
Fri Feb 10 12:29:30 2012
@@ -27,52 +27,52 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertTrue;
 
 public class ChangeLogTest {
+    private final ChangeLog changeLog = new ChangeLog();
 
     @Test
     public void empty() {
-        ChangeLog changeLog = new ChangeLog();
         assertTrue(changeLog.toJsop().isEmpty());
     }
     
     @Test
     public void singleton() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/foo"));
         assertEquals("+\"//foo\":{}", changeLog.toJsop());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/a"));
         assertTrue(changeLog.toJsop().isEmpty());
     }
 
     @Test
     public void tuples() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/c"), path("/d"));
         assertEquals(">\"//c\":\"//d\">\"//a\":\"//b\"", changeLog.toJsop());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/b"), path("/c"));
         assertEquals(">\"//a\":\"//c\"", changeLog.toJsop());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/b"), path("/a"));
         assertTrue(changeLog.toJsop().isEmpty());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/a"));
         changeLog.moveNode(path("/a"), path("/b"));
         assertEquals("+\"//b\":{}", changeLog.toJsop());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.removeNode(path("/b"));
         assertEquals("-\"//a\"", changeLog.toJsop());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/a"));
         changeLog.removeNode(path("/a"));
         assertTrue(changeLog.toJsop().isEmpty());
@@ -80,13 +80,13 @@ public class ChangeLogTest {
 
     @Test
     public void triple() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/b"), path("/c"));
         changeLog.moveNode(path("/c"), path("/d"));
         assertEquals(">\"//a\":\"//d\"", changeLog.toJsop());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/x"), path("/y"));
         changeLog.moveNode(path("/b"), path("/c"));
@@ -95,7 +95,7 @@ public class ChangeLogTest {
     
     @Test
     public void remove() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.removeNode(path("/a/b"));
         changeLog.removeNode(path("/a"));
         assertEquals("-\"//a\"", changeLog.toJsop());
@@ -103,13 +103,13 @@ public class ChangeLogTest {
 
     @Test
     public void removeAdded() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/a"));
         changeLog.addNode(path("/a/b"));
         changeLog.removeNode(path("/a"));
         assertTrue(changeLog.toJsop().isEmpty());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/a"));
         changeLog.addNode(path("/a/b"));
         changeLog.addNode(path("/a/c"));
@@ -119,29 +119,29 @@ public class ChangeLogTest {
     
     @Test
     public void properties() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.setProperty(path("/"), "a", JsonAtom.number(42));
         assertEquals("^\"//a\":42", changeLog.toJsop());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.setProperty(path("/"), "a", JsonAtom.number(42));
         changeLog.setProperty(path("/"), "a", JsonAtom.number(43));
         assertEquals("^\"//a\":43", changeLog.toJsop());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/a"));
         changeLog.setProperty(path("/a"), "a", JsonAtom.number(42));
         changeLog.removeNode(path("/a"));
         assertTrue(changeLog.toJsop().isEmpty());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/a"));
         changeLog.setProperty(path("/a"), "a", JsonAtom.number(42));
         changeLog.setProperty(path("/a"), "b", JsonAtom.number(42));
         changeLog.removeNode(path("/a"));
         assertTrue(changeLog.toJsop().isEmpty());
 
-        changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.setProperty(path("/"), "a", JsonAtom.number(42));
         changeLog.removeProperty(path("/"), "a");
         assertEquals("^\"//a\":null", changeLog.toJsop());
@@ -155,7 +155,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule1_5_9_13() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/c"), path("/d"));
         assertEquals(">\"//c\":\"//d\">\"//a\":\"//b\"", changeLog.toJsop());
@@ -166,7 +166,7 @@ public class ChangeLogTest {
      */
     @Test(expected = IllegalArgumentException.class)
     public void testRule2() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/a/b"), path("/c"));
     }
@@ -176,7 +176,7 @@ public class ChangeLogTest {
      */
     @Test(expected = IllegalArgumentException.class)
     public void testRule3() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/a"), path("/c"));
     }
@@ -186,7 +186,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule4() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a/b"), path("/c"));
         changeLog.moveNode(path("/a"), path("/d"));
         assertEquals(">\"//a\":\"//d\">\"//d/b\":\"//c\"", changeLog.toJsop());
@@ -198,7 +198,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule4a() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a/b"), path("/c"));
         changeLog.moveNode(path("/a"), path("/c/d"));
         assertEquals(">\"//a/b\":\"//c\">\"//a\":\"//c/d\"", changeLog.toJsop());
@@ -210,7 +210,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule4b() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.removeNode(path("/a/b"));
         changeLog.removeNode(path("/a"));
         assertEquals("-\"//a\"", changeLog.toJsop());
@@ -222,7 +222,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule4c() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a/b"), path("/c"));
         changeLog.removeNode(path("/a"));
         assertEquals(">\"//a/b\":\"//c\"-\"//a\"", changeLog.toJsop());
@@ -234,7 +234,7 @@ public class ChangeLogTest {
      */
     @Test(expected = IllegalArgumentException.class)
     public void testRule6() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/c"), path("/a/d"));
     }
@@ -244,7 +244,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule7() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/c"), path("/a"));
         assertEquals(">\"//a\":\"//b\">\"//c\":\"//a\"", changeLog.toJsop());
@@ -255,7 +255,7 @@ public class ChangeLogTest {
      */
     @Test(expected = IllegalArgumentException.class)
     public void testRule8() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a/d"), path("/b"));
         changeLog.moveNode(path("/c"), path("/a"));
     }
@@ -265,7 +265,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule10() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/b/c"), path("/d"));
         assertEquals(">\"//a/c\":\"//d\">\"//a\":\"//b\"", changeLog.toJsop());
@@ -276,7 +276,7 @@ public class ChangeLogTest {
      */
     @Test(expected = IllegalArgumentException.class)
     public void testRule10a() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/b"));
         changeLog.moveNode(path("/b/c"), path("/d"));
     }
@@ -286,7 +286,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule11() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/b"), path("/c"));
         assertEquals(">\"//a\":\"//c\"", changeLog.toJsop());
@@ -297,7 +297,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule12() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b/c"));
         changeLog.moveNode(path("/b"), path("/d"));
         assertEquals(">\"//b\":\"//d\">\"//a\":\"//d/c\"", changeLog.toJsop());
@@ -308,7 +308,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule12a() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b/c"));
         changeLog.removeNode(path("/b"));
         assertEquals("-\"//a\"-\"//b\"", changeLog.toJsop());
@@ -319,7 +319,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule14() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/c"), path("/b/d"));
         assertEquals(">\"//c\":\"//a/d\">\"//a\":\"//b\"", changeLog.toJsop());
@@ -330,7 +330,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule14a() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a/b"), path("/b"));
         changeLog.moveNode(path("/a"), path("/b/d"));
         assertEquals(">\"//a/b\":\"//b\">\"//a\":\"//b/d\"", changeLog.toJsop());
@@ -341,7 +341,7 @@ public class ChangeLogTest {
      */
     @Test
     public void testRule14b() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/b"));
         changeLog.moveNode(path("/c"), path("/b/c"));
         assertEquals("+\"//b\":{}>\"//c\":\"//b/c\"", changeLog.toJsop());
@@ -352,7 +352,7 @@ public class ChangeLogTest {
      */
     @Test(expected = IllegalArgumentException.class)
     public void testRule14c() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.addNode(path("/b"));
         changeLog.moveNode(path("/c"), path("/b/c/d"));
     }
@@ -362,7 +362,7 @@ public class ChangeLogTest {
      */
     @Test(expected = IllegalArgumentException.class)
     public void testRule15() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b"));
         changeLog.moveNode(path("/c"), path("/b"));
     }
@@ -372,7 +372,7 @@ public class ChangeLogTest {
      */
     @Test(expected = IllegalArgumentException.class)
     public void testRule16() {
-        ChangeLog changeLog = new ChangeLog();
+        changeLog.clear();
         changeLog.moveNode(path("/a"), path("/b/d"));
         changeLog.moveNode(path("/c"), path("/b"));
     }



Mime
View raw message