You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2016/10/19 15:12:04 UTC

svn commit: r1765647 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document: LocalDiffCacheTest.java TestNodeObserver.java

Author: chetanm
Date: Wed Oct 19 15:12:04 2016
New Revision: 1765647

URL: http://svn.apache.org/viewvc?rev=1765647&view=rev
Log:
OAK-1312 -  [bundling] Bundle nodes into a document

Refactor the test observor so as to be used in other tests. No functional change

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestNodeObserver.java   (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java?rev=1765647&r1=1765646&r2=1765647&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/LocalDiffCacheTest.java Wed Oct 19 15:12:04 2016
@@ -20,9 +20,6 @@ package org.apache.jackrabbit.oak.plugin
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.Nonnull;
 
 import com.google.common.collect.Maps;
 
@@ -30,7 +27,6 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.cache.CacheStats;
 import org.apache.jackrabbit.oak.plugins.document.LocalDiffCache.Diff;
 import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
-import org.apache.jackrabbit.oak.plugins.observation.NodeObserver;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
 import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -147,66 +143,4 @@ public class LocalDiffCacheTest {
             cs.resetStats();
         }
     }
-
-    //------------------------------------------------------------< TestNodeObserver >---
-
-    private static class TestNodeObserver extends NodeObserver {
-        private final Map<String, Set<String>> added = newHashMap();
-        private final Map<String, Set<String>> deleted = newHashMap();
-        private final Map<String, Set<String>> changed = newHashMap();
-        private final Map<String, Map<String, String>> properties = newHashMap();
-
-        protected TestNodeObserver(String path, String... propertyNames) {
-            super(path, propertyNames);
-        }
-
-        @Override
-        protected void added(
-                @Nonnull String path,
-                @Nonnull Set<String> added,
-                @Nonnull Set<String> deleted,
-                @Nonnull Set<String> changed,
-                @Nonnull Map<String, String> properties,
-                @Nonnull CommitInfo commitInfo) {
-            this.added.put(path, newHashSet(added));
-            if (!properties.isEmpty()) {
-                this.properties.put(path, newHashMap(properties));
-            }
-        }
-
-        @Override
-        protected void deleted(
-                @Nonnull String path,
-                @Nonnull Set<String> added,
-                @Nonnull Set<String> deleted,
-                @Nonnull Set<String> changed,
-                @Nonnull Map<String, String> properties,
-                @Nonnull CommitInfo commitInfo) {
-            this.deleted.put(path, newHashSet(deleted));
-            if (!properties.isEmpty()) {
-                this.properties.put(path, newHashMap(properties));
-            }
-        }
-
-        @Override
-        protected void changed(
-                @Nonnull String path,
-                @Nonnull Set<String> added,
-                @Nonnull Set<String> deleted,
-                @Nonnull Set<String> changed,
-                @Nonnull Map<String, String> properties,
-                @Nonnull CommitInfo commitInfo) {
-            this.changed.put(path, newHashSet(changed));
-            if (!properties.isEmpty()) {
-                this.properties.put(path, newHashMap(properties));
-            }
-        }
-
-        public void reset(){
-            added.clear();
-            deleted.clear();
-            changed.clear();
-            properties.clear();
-        }
-    }
 }

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestNodeObserver.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestNodeObserver.java?rev=1765647&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestNodeObserver.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestNodeObserver.java Wed Oct 19 15:12:04 2016
@@ -0,0 +1,91 @@
+/*
+ * 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.document;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Nonnull;
+
+import org.apache.jackrabbit.oak.plugins.observation.NodeObserver;
+import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
+
+import static com.google.common.collect.Maps.newHashMap;
+import static com.google.common.collect.Sets.newHashSet;
+
+public class TestNodeObserver extends NodeObserver {
+    public final Map<String, Set<String>> added = newHashMap();
+    public final Map<String, Set<String>> deleted = newHashMap();
+    public final Map<String, Set<String>> changed = newHashMap();
+    public final Map<String, Map<String, String>> properties = newHashMap();
+
+    public TestNodeObserver(String path, String... propertyNames) {
+        super(path, propertyNames);
+    }
+
+    @Override
+    protected void added(
+            @Nonnull String path,
+            @Nonnull Set<String> added,
+            @Nonnull Set<String> deleted,
+            @Nonnull Set<String> changed,
+            @Nonnull Map<String, String> properties,
+            @Nonnull CommitInfo commitInfo) {
+        this.added.put(path, newHashSet(added));
+        if (!properties.isEmpty()) {
+            this.properties.put(path, newHashMap(properties));
+        }
+    }
+
+    @Override
+    protected void deleted(
+            @Nonnull String path,
+            @Nonnull Set<String> added,
+            @Nonnull Set<String> deleted,
+            @Nonnull Set<String> changed,
+            @Nonnull Map<String, String> properties,
+            @Nonnull CommitInfo commitInfo) {
+        this.deleted.put(path, newHashSet(deleted));
+        if (!properties.isEmpty()) {
+            this.properties.put(path, newHashMap(properties));
+        }
+    }
+
+    @Override
+    protected void changed(
+            @Nonnull String path,
+            @Nonnull Set<String> added,
+            @Nonnull Set<String> deleted,
+            @Nonnull Set<String> changed,
+            @Nonnull Map<String, String> properties,
+            @Nonnull CommitInfo commitInfo) {
+        this.changed.put(path, newHashSet(changed));
+        if (!properties.isEmpty()) {
+            this.properties.put(path, newHashMap(properties));
+        }
+    }
+
+    public void reset(){
+        added.clear();
+        deleted.clear();
+        changed.clear();
+        properties.clear();
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/TestNodeObserver.java
------------------------------------------------------------------------------
    svn:eol-style = native