jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1448020 - in /jackrabbit/oak/trunk: oak-core/pom.xml oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java oak-parent/pom.xml
Date Wed, 20 Feb 2013 07:47:12 GMT
Author: jukka
Date: Wed Feb 20 07:47:11 2013
New Revision: 1448020

URL: http://svn.apache.org/r1448020
Log:
OAK-630: SegmentMK: Implement compareAgainstBaseState

Add basic test case with EasyMock

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/pom.xml
    jackrabbit/oak/trunk/oak-parent/pom.xml

Modified: jackrabbit/oak/trunk/oak-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/pom.xml?rev=1448020&r1=1448019&r2=1448020&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-core/pom.xml Wed Feb 20 07:47:11 2013
@@ -206,6 +206,11 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>oak-it-mk</artifactId>
       <version>${project.version}</version>

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java?rev=1448020&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompareAgainstBaseStateTest.java
Wed Feb 20 07:47:11 2013
@@ -0,0 +1,156 @@
+/*
+ * 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.oak.plugins.segment;
+
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test case for ensuring that segment size remains within bounds.
+ */
+public class CompareAgainstBaseStateTest {
+
+    private final SegmentStore store = new MemoryStore();
+
+    private final SegmentWriter writer = new SegmentWriter(store);
+
+    private final SegmentReader reader = new SegmentReader(store);
+
+    private final NodeStateDiff diff = EasyMock.createMock(NodeStateDiff.class);
+
+    private final NodeBuilder builder = MemoryNodeState.EMPTY_NODE.builder();
+
+    @Before
+    public void setUp() {
+        builder.setProperty("foo", "abc");
+        builder.setProperty("bar", 123);
+        builder.child("baz");
+    }
+
+    @Test
+    public void testSameState() {
+        NodeState node = persist(builder);
+
+        EasyMock.replay(diff);
+
+        node.compareAgainstBaseState(node, diff);
+        EasyMock.verify(diff);
+    }
+
+    @Test
+    public void testEqualState() {
+        NodeState before = persist(builder);
+        NodeState after = persist(builder);
+
+        EasyMock.replay(diff);
+
+        after.compareAgainstBaseState(before, diff);
+        EasyMock.verify(diff);
+    }
+
+    @Test
+    public void testPropertyAdded() {
+        NodeState before = persist(builder);
+        builder.setProperty("test", "test");
+        NodeState after = persist(builder);
+
+        diff.propertyAdded(after.getProperty("test"));
+        EasyMock.replay(diff);
+
+        after.compareAgainstBaseState(before, diff);
+        EasyMock.verify(diff);
+    }
+
+    @Test
+    public void testPropertyChanged() {
+        NodeState before = persist(builder);
+        builder.setProperty("foo", "test");
+        NodeState after = persist(builder);
+
+        diff.propertyChanged(
+                before.getProperty("foo"), after.getProperty("foo"));
+        EasyMock.replay(diff);
+
+        after.compareAgainstBaseState(before, diff);
+        EasyMock.verify(diff);
+    }
+
+    @Test
+    public void testPropertyDeleted() {
+        NodeState before = persist(builder);
+        builder.removeProperty("foo");
+        NodeState after = persist(builder);
+
+        diff.propertyDeleted(before.getProperty("foo"));
+        EasyMock.replay(diff);
+
+        after.compareAgainstBaseState(before, diff);
+        EasyMock.verify(diff);
+    }
+
+    @Test
+    public void testChildNodeAdded() {
+        NodeState before = persist(builder);
+        builder.child("test");
+        NodeState after = persist(builder);
+
+        diff.childNodeAdded("test", after.getChildNode("test"));
+        EasyMock.replay(diff);
+
+        after.compareAgainstBaseState(before, diff);
+        EasyMock.verify(diff);
+    }
+
+    @Test
+    public void testChildNodeChanged() {
+        NodeState before = persist(builder);
+        builder.child("baz").setProperty("test", "test");
+        NodeState after = persist(builder);
+
+        diff.childNodeChanged(
+                "baz", before.getChildNode("baz"), after.getChildNode("baz"));
+        EasyMock.replay(diff);
+
+        after.compareAgainstBaseState(before, diff);
+        EasyMock.verify(diff);
+    }
+
+    @Test
+    public void testChildNodeDeleted() {
+        NodeState before = persist(builder);
+        builder.removeNode("baz");
+        NodeState after = persist(builder);
+
+        diff.childNodeDeleted("baz", before.getChildNode("baz"));
+        EasyMock.replay(diff);
+
+        after.compareAgainstBaseState(before, diff);
+        EasyMock.verify(diff);
+    }
+
+    private NodeState persist(NodeBuilder builder) {
+        RecordId id = writer.writeNode(builder.getNodeState());
+        writer.flush();
+        return new SegmentNodeState(reader, id);
+    }
+
+}

Modified: jackrabbit/oak/trunk/oak-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-parent/pom.xml?rev=1448020&r1=1448019&r2=1448020&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-parent/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-parent/pom.xml Wed Feb 20 07:47:11 2013
@@ -225,14 +225,19 @@
       </dependency>
       <dependency>
         <groupId>org.mongodb</groupId>
-         <artifactId>mongo-java-driver</artifactId>
-         <version>2.9.1</version>
-       </dependency>
-       <dependency>
-         <groupId>com.google.guava</groupId>
-         <artifactId>guava</artifactId>
-         <version>13.0.1</version>
-       </dependency>
+        <artifactId>mongo-java-driver</artifactId>
+        <version>2.9.1</version>
+      </dependency>
+      <dependency>
+        <groupId>com.google.guava</groupId>
+        <artifactId>guava</artifactId>
+        <version>13.0.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.easymock</groupId>
+        <artifactId>easymock</artifactId>
+        <version>3.1</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 



Mime
View raw message