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 ro...@apache.org on 2017/07/12 09:27:48 UTC
svn commit: r1801708 - in /jackrabbit/oak/trunk/oak-store-composite/src:
main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java
test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java
Author: rombert
Date: Wed Jul 12 09:27:48 2017
New Revision: 1801708
URL: http://svn.apache.org/viewvc?rev=1801708&view=rev
Log:
OAK-6447 - CompositeNodeStore initialisation fails if
ignoreReadOnlyWrites config property is not set
Added fix + wrote a couple of unit tests.
Added:
jackrabbit/oak/trunk/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java
Modified:
jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java
Modified: jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java?rev=1801708&r1=1801707&r2=1801708&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreService.java Wed Jul 12 09:27:48 2017
@@ -97,7 +97,7 @@ public class CompositeNodeStoreService {
@Activate
protected void activate(ComponentContext context, Map<String, ?> config) {
this.context = context;
- ignoreReadOnlyWritePaths = PropertiesUtil.toStringArray(config.get(PROP_IGNORE_READ_ONLY_WRITES));
+ ignoreReadOnlyWritePaths = PropertiesUtil.toStringArray(config.get(PROP_IGNORE_READ_ONLY_WRITES), new String[0]);
partialReadOnly = PropertiesUtil.toBoolean(config.get(PROP_PARTIAL_READ_ONLY), true);
registerCompositeNodeStore();
}
Added: jackrabbit/oak/trunk/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java?rev=1801708&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java (added)
+++ jackrabbit/oak/trunk/oak-store-composite/src/test/java/org/apache/jackrabbit/oak/composite/CompositeNodeStoreServiceTest.java Wed Jul 12 09:27:48 2017
@@ -0,0 +1,111 @@
+/*
+ * 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.composite;
+
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
+import org.apache.jackrabbit.oak.spi.mount.MountInfoProvider;
+import org.apache.jackrabbit.oak.spi.mount.Mounts;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
+import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
+import org.junit.Rule;
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class CompositeNodeStoreServiceTest {
+
+ @Rule
+ public final OsgiContext ctx = new OsgiContext();
+
+ /**
+ * Verifies that a minimally-configured <tt>CompositeNodeStore</tt> can be registered successfully
+ */
+ @Test
+ public void bootstrap() {
+
+ MemoryNodeStore mount = new MemoryNodeStore();
+ MemoryNodeStore global = new MemoryNodeStore();
+
+ MountInfoProvider mip = Mounts.newBuilder().readOnlyMount("libs", "/libs", "/apps").build();
+
+ ctx.registerService(MountInfoProvider.class, mip);
+ ctx.registerService(NodeStoreProvider.class, new SimpleNodeStoreProvider(global), ImmutableMap.of("role", "composite:global", "registerDescriptors", Boolean.TRUE));
+ ctx.registerService(NodeStoreProvider.class, new SimpleNodeStoreProvider(mount), ImmutableMap.of("role", "composite:mount:libs"));
+
+ ctx.registerInjectActivateService(new CompositeNodeStoreService());
+
+ assertThat("No NodeStore registered", ctx.getService(NodeStore.class), notNullValue());
+ }
+
+ /**
+ * Verifies that a missing mount will result in the node store not being registered
+ */
+ @Test
+ public void bootstrap_missingMount() {
+
+ MemoryNodeStore mount = new MemoryNodeStore();
+ MemoryNodeStore global = new MemoryNodeStore();
+
+ MountInfoProvider mip = Mounts.newBuilder().readOnlyMount("libs", "/libs", "/apps").readOnlyMount("missing", "/missing").build();
+
+ ctx.registerService(MountInfoProvider.class, mip);
+ ctx.registerService(NodeStoreProvider.class, new SimpleNodeStoreProvider(global), ImmutableMap.of("role", "composite:global", "registerDescriptors", Boolean.TRUE));
+ ctx.registerService(NodeStoreProvider.class, new SimpleNodeStoreProvider(mount), ImmutableMap.of("role", "composite:mount:libs"));
+
+ ctx.registerInjectActivateService(new CompositeNodeStoreService());
+
+ assertThat("NodeStore registered, but it should not have been", ctx.getService(NodeStore.class), nullValue());
+ }
+
+ /**
+ * Verifies that a missing global mount will result in the node store not being registered
+ */
+ @Test
+ public void bootstrap_missingGlobalMount() {
+
+ MemoryNodeStore mount = new MemoryNodeStore();
+
+ MountInfoProvider mip = Mounts.newBuilder().readOnlyMount("libs", "/libs", "/apps").build();
+
+ ctx.registerService(MountInfoProvider.class, mip);
+ ctx.registerService(NodeStoreProvider.class, new SimpleNodeStoreProvider(mount), ImmutableMap.of("role", "composite:mount:libs"));
+
+ ctx.registerInjectActivateService(new CompositeNodeStoreService());
+
+ assertThat("NodeStore registered, but it should not have been", ctx.getService(NodeStore.class), nullValue());
+ }
+
+ private static class SimpleNodeStoreProvider implements NodeStoreProvider {
+
+ private final NodeStore nodeStore;
+
+ private SimpleNodeStoreProvider(NodeStore nodeStore) {
+ this.nodeStore = nodeStore;
+ }
+
+ @Override
+ public NodeStore getNodeStore() {
+ return nodeStore;
+ }
+
+ }
+}