jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1492831 - in /jackrabbit/oak/trunk: oak-core/src/test/java/org/apache/jackrabbit/oak/ oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/ oak-mk/src/main/java/org/apache/jackrabbit/mk/core/
Date Thu, 13 Jun 2013 19:44:02 GMT
Author: mreutegg
Date: Thu Jun 13 19:44:02 2013
New Revision: 1492831

URL: http://svn.apache.org/r1492831
Log:
OAK-868: KernelNodeState.processJsonDiff throws IAE on hidden items

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/NodeStoreTest.java
  (contents, props changed)
      - copied, changed from r1492804, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
Modified:
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java?rev=1492831&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/NodeStoreFixture.java
Thu Jun 13 19:44:02 2013
@@ -0,0 +1,95 @@
+/*
+ * 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;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.mongomk.MongoMK;
+import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStore;
+import org.apache.jackrabbit.oak.plugins.segment.memory.MemoryStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+
+/**
+ * NodeStore fixture for parametrized tests.
+ */
+public abstract class NodeStoreFixture {
+
+    public static final NodeStoreFixture SEGMENT_MK = new NodeStoreFixture() {
+        @Override
+        public NodeStore createNodeStore() {
+            return new SegmentNodeStore(new MemoryStore());
+        }
+
+        @Override
+        public void dispose(NodeStore nodeStore) {
+        }
+    };
+
+    public static final NodeStoreFixture MONGO_MK = new NodeStoreFixture() {
+        @Override
+        public NodeStore createNodeStore() {
+            return new CloseableNodeStore(new MongoMK.Builder().open());
+        }
+
+        @Override
+        public void dispose(NodeStore nodeStore) {
+            if (nodeStore instanceof Closeable) {
+                try {
+                    ((Closeable) nodeStore).close();
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    };
+
+    public static final NodeStoreFixture MK_IMPL = new NodeStoreFixture() {
+        @Override
+        public NodeStore createNodeStore() {
+            return new KernelNodeStore(new MicroKernelImpl());
+        }
+
+        @Override
+        public void dispose(NodeStore nodeStore) {
+        }
+    };
+
+    public abstract NodeStore createNodeStore();
+
+    public abstract void dispose(NodeStore nodeStore);
+
+    private static class CloseableNodeStore
+            extends KernelNodeStore implements Closeable {
+
+        private final MongoMK kernel;
+
+        public CloseableNodeStore(MongoMK kernel) {
+            super(kernel);
+            this.kernel = kernel;
+        }
+
+        @Override
+        public void close() throws IOException {
+            kernel.dispose();
+        }
+    }
+}

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/NodeStoreTest.java
(from r1492804, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/NodeStoreTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/NodeStoreTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java&r1=1492804&r2=1492831&rev=1492831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/NodeStoreTest.java
Thu Jun 13 19:44:02 2013
@@ -23,13 +23,14 @@ import static org.apache.jackrabbit.oak.
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.runners.Parameterized.Parameters;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.NodeStoreFixture;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.plugins.memory.MultiStringPropertyState;
@@ -39,28 +40,60 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
+import org.junit.After;
+import org.junit.Assume;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
-public class KernelNodeStoreTest {
+@RunWith(value = Parameterized.class)
+public class NodeStoreTest {
 
-    private KernelNodeStore store;
+    @Parameters
+    public static Collection<Object[]> fixtures() {
+        Object[][] fixtures = new Object[][] {
+                {NodeStoreFixture.MK_IMPL},
+                {NodeStoreFixture.MONGO_MK},
+                {NodeStoreFixture.SEGMENT_MK},
+        };
+        return Arrays.asList(fixtures);
+    }
+
+    private NodeStore store;
 
     private NodeState root;
 
+    private NodeStoreFixture fixture;
+
+    public NodeStoreTest(NodeStoreFixture fixture) {
+        this.fixture = fixture;
+    }
+
     @Before
-    public void setUp() {
-        MicroKernel kernel = new MicroKernelImpl();
-        String jsop =
-                "+\"test\":{\"a\":1,\"b\":2,\"c\":3,"
-                + "\"x\":{},\"y\":{},\"z\":{}}";
-        kernel .commit("/", jsop, null, "test data");
-        store = new KernelNodeStore(kernel);
+    public void setUp() throws Exception {
+        store = fixture.createNodeStore();
+        NodeStoreBranch branch = store.branch();
+        NodeBuilder builder = branch.getHead().builder();
+        NodeBuilder test = builder.child("test");
+        test.setProperty("a", 1);
+        test.setProperty("b", 2);
+        test.setProperty("c", 3);
+        test.child("x");
+        test.child("y");
+        test.child("z");
+        branch.setRoot(builder.getNodeState());
+        branch.merge(EmptyHook.INSTANCE);
         root = store.getRoot();
     }
 
+    @After
+    public void tearDown() throws Exception {
+        fixture.dispose(store);
+    }
+
     @Test
     public void getRoot() {
         assertEquals(root, store.getRoot());
@@ -122,8 +155,10 @@ public class KernelNodeStoreTest {
 
     @Test
     public void afterCommitHook() throws CommitFailedException {
+        // this test only works with a KernelNodeStore
+        Assume.assumeTrue(store instanceof KernelNodeStore);
         final NodeState[] states = new NodeState[2]; // { before, after }
-        store.setObserver(new Observer() {
+        ((KernelNodeStore) store).setObserver(new Observer() {
             @Override
             public void contentChanged(NodeState before, NodeState after) {
                 states[0] = before;
@@ -194,6 +229,8 @@ public class KernelNodeStoreTest {
 
     @Test
     public void manyChildNodes() throws CommitFailedException {
+        // OAK-872
+        Assume.assumeTrue(fixture != NodeStoreFixture.MONGO_MK);
         NodeStoreBranch branch = store.branch();
         NodeBuilder root = branch.getHead().builder();
         NodeBuilder parent = root.child("parent");
@@ -296,8 +333,9 @@ public class KernelNodeStoreTest {
     }
 
     @Test
-    @Ignore
     public void compareAgainstBaseState100() throws CommitFailedException {
+        // OAK-872
+        Assume.assumeTrue(fixture != NodeStoreFixture.MONGO_MK);
         compareAgainstBaseState(KernelNodeState.MAX_CHILD_NODE_NAMES);
     }
 

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/NodeStoreTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java?rev=1492831&r1=1492830&r2=1492831&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/core/MicroKernelImpl.java
Thu Jun 13 19:44:02 2013
@@ -317,8 +317,8 @@ public class MicroKernelImpl implements 
         try {
             if ("/".equals(path)) {
                 StoredCommit toCommit = rep.getCommit(toRevisionId);
-                if (toCommit.getParentId().equals(fromRevisionId)) {
-                    // specified range spans a single commit:
+                if (toCommit.getParentId().equals(fromRevisionId) && depth == -1)
{
+                    // specified range spans a single commit and depth is not limited:
                     // use diff stored in commit instead of building it dynamically
                     return toCommit.getChanges();
                 }



Mime
View raw message