jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meteata...@apache.org
Subject svn commit: r1440430 - in /jackrabbit/oak/trunk/oak-mongomk/src: main/java/org/apache/jackrabbit/mongomk/impl/model/ test/java/org/apache/jackrabbit/mongomk/impl/ test/java/org/apache/jackrabbit/mongomk/impl/model/
Date Wed, 30 Jan 2013 14:24:44 GMT
Author: meteatamel
Date: Wed Jan 30 14:24:44 2013
New Revision: 1440430

URL: http://svn.apache.org/viewvc?rev=1440430&view=rev
Log:
OAK-596 - Microkernel.diff returns empty diff when there are differences

Fixed a bu in MongoNode#copy

Added:
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/model/MongoNodeTest.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/MongoNode.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKDiffTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/MongoNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/MongoNode.java?rev=1440430&r1=1440429&r2=1440430&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/MongoNode.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/impl/model/MongoNode.java
Wed Jan 30 14:24:44 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.mongomk.impl.model;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -148,6 +149,11 @@ public class MongoNode extends BasicDBOb
     public MongoNode copy() {
         MongoNode copy = new MongoNode();
         copy.putAll((Map) super.copy());
+        List<String> children = getChildren();
+        if (children != null) {
+            copy.put(KEY_CHILDREN, new ArrayList<String>(children));
+        }
+        copy.put(KEY_PROPERTIES, new HashMap<String, Object>(getProperties()));
         return copy;
     }
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKDiffTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKDiffTest.java?rev=1440430&r1=1440429&r2=1440430&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKDiffTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/MongoMKDiffTest.java
Wed Jan 30 14:24:44 2013
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.mongomk.im
 
 import org.apache.jackrabbit.mongomk.BaseMongoMicroKernelTest;
 import org.json.simple.JSONObject;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.assertFalse;
@@ -31,9 +30,7 @@ import static org.junit.Assert.assertTru
 public class MongoMKDiffTest extends BaseMongoMicroKernelTest {
 
     @Test
-    @Ignore("OAK-596")
     public void oak_596() {
-        String rev0 = mk.getHeadRevision();
         String rev1 = mk.commit("/", "+\"node1\":{\"node2\":{\"prop1\":\"val1\",\"prop2\":\"val2\"}}",
null, null);
         String rev2 = mk.commit("/", "^\"node1/node2/prop1\":\"val1 new\" ^\"node1/node2/prop2\":null",
null, null);
 

Added: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/model/MongoNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/model/MongoNodeTest.java?rev=1440430&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/model/MongoNodeTest.java
(added)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/model/MongoNodeTest.java
Wed Jan 30 14:24:44 2013
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.mongomk.impl.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class MongoNodeTest {
+
+    @Test
+    public void copyOriginalNotChanged() throws Exception {
+
+        // Create a node with properties
+        MongoNode node = new MongoNode();
+        node.setBranchId("branchId");
+        List<String> children = new ArrayList<String>();
+        children.add("child");
+        node.setChildren(children);
+        node.setDeleted(true);
+        node.setPath("path");
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put("key", "value");
+        node.setProperties(properties);
+        node.setRevisionId(0);
+
+        // Copy the node and change properties
+        MongoNode copy = node.copy();
+        copy.setBranchId("branchId2");
+        List<String> copyChildren = copy.getChildren();
+        copyChildren.add("child2");
+        copy.setDeleted(false);
+        copy.setPath("path2");
+        Map<String, Object> copyProperties = copy.getProperties();
+        copyProperties.put("key", "valuee");
+        copyProperties.put("key2", "value2");
+        copy.setRevisionId(1);
+
+        // Assert that original node did not change
+        assertEquals("branchId", node.getBranchId());
+        children = node.getChildren();
+        assertEquals(1, children.size());
+        assertEquals("child", children.get(0));
+        assertTrue(node.isDeleted());
+        assertEquals("path", node.getPath());
+        properties = node.getProperties();
+        assertEquals(1, properties.size());
+        assertEquals("value", properties.get("key"));
+        assertTrue(0 == node.getRevisionId());
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/impl/model/MongoNodeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message