Author: tomekr
Date: Wed Sep 21 19:35:03 2016
New Revision: 1761799

URL: http://svn.apache.org/viewvc?rev=1761799&view=rev
Log:
OAK-4655: Enable configuring multiple segment nodestore instances in same setup

-added tests
-allow to configure customBlobStore (always enabled for 'secondary' role)
-default base directory name depends on the role

Added:
    
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactoryTest.java
    
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactoryTest.java
Modified:
    
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactory.java
    
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
    
jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactory.java
    
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java

Modified: 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactory.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactory.java?rev=1761799&r1=1761798&r2=1761799&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactory.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactory.java
 Wed Sep 21 19:35:03 2016
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.segmen
 import static com.google.common.base.Preconditions.checkState;
 import static 
org.apache.jackrabbit.oak.osgi.OsgiUtil.lookupConfigurationThenFramework;
 import static 
org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder;
+import static 
org.apache.jackrabbit.oak.spi.blob.osgi.SplitBlobStoreService.ONLY_STANDALONE_TARGET;
 import static 
org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean;
 
 import java.io.File;
@@ -32,12 +33,15 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.jackrabbit.oak.commons.PropertiesUtil;
 import org.apache.jackrabbit.oak.osgi.OsgiWhiteboard;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder;
 import org.apache.jackrabbit.oak.segment.file.FileStoreStatsMBean;
 import org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.spi.state.ProxyNodeStore;
@@ -62,8 +66,7 @@ import org.slf4j.LoggerFactory;
         description = "Factory allowing configuration of adjacent instances of 
" +
                       "NodeStore implementation based on Segment model besides 
a default SegmentNodeStore in same setup."
 )
-public class SegmentNodeStoreFactory extends ProxyNodeStore
-        implements SegmentStoreProvider {
+public class SegmentNodeStoreFactory extends ProxyNodeStore {
 
     public static final String NAME = "name";
 
@@ -101,6 +104,13 @@ public class SegmentNodeStoreFactory ext
     )
     public static final String CACHE = "cache";
 
+    @Property(boolValue = false,
+            label = "Custom BlobStore",
+            description = "Boolean value indicating that a custom BlobStore is 
to be used. " +
+                    "By default large binary content would be stored within 
segment tar files"
+    )
+    public static final String CUSTOM_BLOB_STORE = "customBlobStore";
+
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     private String name;
@@ -111,6 +121,10 @@ public class SegmentNodeStoreFactory ext
 
     private ComponentContext context;
 
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,
+            policy = ReferencePolicy.DYNAMIC, target = ONLY_STANDALONE_TARGET)
+    private volatile BlobStore blobStore;
+
     @Reference
     private StatisticsProvider statisticsProvider = StatisticsProvider.NOOP;
 
@@ -118,25 +132,42 @@ public class SegmentNodeStoreFactory ext
     private Registration fileStoreStatsMBean;
     private WhiteboardExecutor executor;
 
+    private boolean customBlobStore;
+
+    private String role;
+
     @Override
     protected SegmentNodeStore getNodeStore() {
         checkState(segmentNodeStore != null, "service must be activated when 
used");
         return segmentNodeStore;
     }
-    
-    private String getRole() {
-        String role = PropertiesUtil.toString(property(ROLE), null);
-        return role;
-    }
-    
+
     @Activate
     public void activate(ComponentContext context) throws IOException {
         this.context = context;
-        log.info("activate: SegmentNodeStore '"+getRole()+"' starting.");
+        this.name = PropertiesUtil.toString(context.getProperties().get(NAME), 
"SegmentNodeStore instance");
+        this.role = property(ROLE);
+        //In secondaryNodeStore mode customBlobStore is always enabled
+        this.customBlobStore = 
Boolean.parseBoolean(property(CUSTOM_BLOB_STORE)) || isSecondaryStoreMode();
+        log.info("activate: SegmentNodeStore '"+role+"' starting.");
+
+        if (blobStore == null && customBlobStore) {
+            log.info("BlobStore use enabled. SegmentNodeStore would be 
initialized when BlobStore would be available");
+        } else {
+            registerNodeStore();
+        }
+    }
 
+    protected void bindBlobStore(BlobStore blobStore) throws IOException {
+        this.blobStore = blobStore;
         registerNodeStore();
     }
 
+    protected void unbindBlobStore(BlobStore blobStore){
+        this.blobStore = null;
+        unregisterNodeStore();
+    }
+
     @Deactivate
     public void deactivate() {
         unregisterNodeStore();
@@ -152,21 +183,20 @@ public class SegmentNodeStoreFactory ext
     }
 
     private synchronized void registerNodeStore() throws IOException {
-        if (registerSegmentStore()) {
-
-            if (getRole() != null) {
-                registerNodeStoreProvider();
-                return;
-            }
-
+        if (registerSegmentStore() && role != null) {
+            registerNodeStoreProvider();
         }
     }
 
+    private boolean isSecondaryStoreMode() {
+        return "secondary".equals(role);
+    }
+
     private void registerNodeStoreProvider() {
         SegmentNodeStore.SegmentNodeStoreBuilder nodeStoreBuilder = 
SegmentNodeStoreBuilders.builder(store);
         segmentNodeStore = nodeStoreBuilder.build();
         Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put(NodeStoreProvider.ROLE, getRole());
+        props.put(NodeStoreProvider.ROLE, role);
         storeRegistration = 
context.getBundleContext().registerService(NodeStoreProvider.class.getName(), 
new NodeStoreProvider() {
                     @Override
                     public NodeStore getNodeStore() {
@@ -174,7 +204,7 @@ public class SegmentNodeStoreFactory ext
                     }
                 },
                 props);
-        log.info("Registered NodeStoreProvider backed by SegmentNodeStore of 
type '{}'", getRole());
+        log.info("Registered NodeStoreProvider backed by SegmentNodeStore of 
type '{}'", role);
     }
 
     private boolean registerSegmentStore() throws IOException {
@@ -193,6 +223,11 @@ public class SegmentNodeStoreFactory ext
                 .withMemoryMapping(getMode().equals("64"))
                 .withStatisticsProvider(statisticsProvider);
 
+        if (customBlobStore) {
+            log.info("Initializing SegmentNodeStore with BlobStore [{}]", 
blobStore);
+            builder.withBlobStore(blobStore);
+        }
+
         try {
             store = builder.build();
         } catch (InvalidFileStoreVersionException e) {
@@ -212,7 +247,7 @@ public class SegmentNodeStoreFactory ext
                 FileStoreStatsMBean.class,
                 store.getStats(),
                 FileStoreStatsMBean.TYPE,
-                "FileStore '" + getRole() + "' statistics"
+                "FileStore '" + role + "' statistics"
         );
 
         return true;
@@ -240,7 +275,11 @@ public class SegmentNodeStoreFactory ext
             return new File(directory);
         }
 
-        return new File("tarmk");
+        if (role == null) {
+            return new File("tarmk");
+        } else {
+            return new File("tarmk-" + role);
+        }
     }
 
     private File getDirectory() {
@@ -289,20 +328,11 @@ public class SegmentNodeStoreFactory ext
         return lookupConfigurationThenFramework(context, name);
     }
 
-    /**
-     * needed for situations where you have to unwrap the
-     * SegmentNodeStoreService, to get the SegmentStore, like the failover
-     */
-    @Override
-    public SegmentStore getSegmentStore() {
-        return store;
-    }
-
     //------------------------------------------------------------< Object >--
 
     @Override
     public String toString() {
-        return name + ": " + segmentNodeStore + "[role:" + getRole() + "]";
+        return name + ": " + segmentNodeStore + "[role:" + role + "]";
     }
 
 }

Added: 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactoryTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactoryTest.java?rev=1761799&view=auto
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactoryTest.java
 (added)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreFactoryTest.java
 Wed Sep 21 19:35:03 2016
@@ -0,0 +1,66 @@
+/*
+ * 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.segment;
+
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static com.google.common.collect.Maps.newHashMap;
+import static org.apache.sling.testing.mock.osgi.MockOsgi.deactivate;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class SegmentNodeStoreFactoryTest extends SegmentNodeStoreServiceTest {
+
+    private SegmentNodeStoreFactory segmentNodeStoreFactory;
+
+    @Test
+    @Ignore
+    public void nodeStoreProvider() throws Exception {
+    }
+
+    @Override
+    protected void registerSegmentNodeStoreService(boolean customBlobStore) {
+        Map<String, Object> properties = newHashMap();
+
+        properties.put(SegmentNodeStoreFactory.ROLE, "some-role");
+        properties.put(SegmentNodeStoreFactory.CUSTOM_BLOB_STORE, 
customBlobStore);
+        properties.put(SegmentNodeStoreFactory.DIRECTORY, 
folder.getRoot().getAbsolutePath());
+
+        segmentNodeStoreFactory = context.registerInjectActivateService(new 
SegmentNodeStoreFactory(), properties);
+    }
+
+    @Override
+    protected void unregisterSegmentNodeStoreService() {
+        deactivate(segmentNodeStoreFactory);
+    }
+
+    @Override
+    protected void assertServiceActivated() {
+        assertNotNull(context.getService(NodeStoreProvider.class));
+    }
+
+    @Override
+    protected void assertServiceNotActivated() {
+        assertNull(context.getService(NodeStoreProvider.class));
+    }
+}
\ No newline at end of file

Modified: 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java?rev=1761799&r1=1761798&r2=1761799&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/SegmentNodeStoreServiceTest.java
 Wed Sep 21 19:35:03 2016
@@ -142,7 +142,7 @@ public class SegmentNodeStoreServiceTest
 
     private SegmentNodeStoreService segmentNodeStoreService;
 
-    private void registerSegmentNodeStoreService(boolean customBlobStore) {
+    protected void registerSegmentNodeStoreService(boolean customBlobStore) {
         Map<String, Object> properties = newHashMap();
 
         properties.put(SegmentNodeStoreService.CUSTOM_BLOB_STORE, 
customBlobStore);
@@ -151,7 +151,7 @@ public class SegmentNodeStoreServiceTest
         segmentNodeStoreService = context.registerInjectActivateService(new 
SegmentNodeStoreService(), properties);
     }
 
-    private void unregisterSegmentNodeStoreService() {
+    protected void unregisterSegmentNodeStoreService() {
         deactivate(segmentNodeStoreService);
     }
 
@@ -165,12 +165,12 @@ public class SegmentNodeStoreServiceTest
         blobStore.unregister();
     }
 
-    private void assertServiceActivated() {
+    protected void assertServiceActivated() {
         assertNotNull(context.getService(NodeStore.class));
         assertNotNull(context.getService(SegmentStoreProvider.class));
     }
 
-    private void assertServiceNotActivated() {
+    protected void assertServiceNotActivated() {
         assertNull(context.getService(NodeStore.class));
         assertNull(context.getService(SegmentStoreProvider.class));
     }

Modified: 
jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactory.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactory.java?rev=1761799&r1=1761798&r2=1761799&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactory.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactory.java
 Wed Sep 21 19:35:03 2016
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.plugin
 
 import static com.google.common.base.Preconditions.checkState;
 import static 
org.apache.jackrabbit.oak.osgi.OsgiUtil.lookupConfigurationThenFramework;
+import static 
org.apache.jackrabbit.oak.spi.blob.osgi.SplitBlobStoreService.ONLY_STANDALONE_TARGET;
 import static 
org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.registerMBean;
 
 import java.io.File;
@@ -31,12 +32,15 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.jackrabbit.oak.commons.PropertiesUtil;
 import org.apache.jackrabbit.oak.osgi.OsgiWhiteboard;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore.Builder;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStoreStatsMBean;
 import 
org.apache.jackrabbit.oak.plugins.segment.file.InvalidFileStoreVersionException;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
 import org.apache.jackrabbit.oak.spi.state.ProxyNodeStore;
@@ -61,8 +65,7 @@ import org.slf4j.LoggerFactory;
         description = "Factory allowing configuration of adjacent instances of 
" +
                       "NodeStore implementation based on Segment model besides 
a default SegmentNodeStore in same setup."
 )
-public class SegmentNodeStoreFactory extends ProxyNodeStore
-        implements SegmentStoreProvider {
+public class SegmentNodeStoreFactory extends ProxyNodeStore {
 
     public static final String NAME = "name";
 
@@ -99,7 +102,14 @@ public class SegmentNodeStoreFactory ext
             description = "Cache size for storing most recently used Segments"
     )
     public static final String CACHE = "cache";
-    
+
+    @Property(boolValue = false,
+            label = "Custom BlobStore",
+            description = "Boolean value indicating that a custom BlobStore is 
to be used. " +
+                    "By default large binary content would be stored within 
segment tar files"
+    )
+    public static final String CUSTOM_BLOB_STORE = "customBlobStore";
+
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     private String name;
@@ -110,6 +120,10 @@ public class SegmentNodeStoreFactory ext
 
     private ComponentContext context;
 
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY,
+            policy = ReferencePolicy.DYNAMIC, target = ONLY_STANDALONE_TARGET)
+    private volatile BlobStore blobStore;
+
     @Reference
     private StatisticsProvider statisticsProvider = StatisticsProvider.NOOP;
 
@@ -117,25 +131,42 @@ public class SegmentNodeStoreFactory ext
     private Registration fileStoreStatsMBean;
     private WhiteboardExecutor executor;
 
+    private boolean customBlobStore;
+
+    private String role;
+
     @Override
     protected SegmentNodeStore getNodeStore() {
         checkState(segmentNodeStore != null, "service must be activated when 
used");
         return segmentNodeStore;
     }
-    
-    private String getRole() {
-        String role = PropertiesUtil.toString(property(ROLE), null);
-        return role;
-    }
-    
+
     @Activate
     public void activate(ComponentContext context) throws IOException {
         this.context = context;
-        log.info("activate: SegmentNodeStore '"+getRole()+"' starting.");
+        this.name = PropertiesUtil.toString(context.getProperties().get(NAME), 
"SegmentNodeStore instance");
+        this.role = property(ROLE);
+        //In secondaryNodeStore mode customBlobStore is always enabled
+        this.customBlobStore = 
Boolean.parseBoolean(property(CUSTOM_BLOB_STORE)) || isSecondaryStoreMode();
+        log.info("activate: SegmentNodeStore '"+role+"' starting.");
+
+        if (blobStore == null && customBlobStore) {
+            log.info("BlobStore use enabled. SegmentNodeStore would be 
initialized when BlobStore would be available");
+        } else {
+            registerNodeStore();
+        }
+    }
 
+    protected void bindBlobStore(BlobStore blobStore) throws IOException {
+        this.blobStore = blobStore;
         registerNodeStore();
     }
 
+    protected void unbindBlobStore(BlobStore blobStore){
+        this.blobStore = null;
+        unregisterNodeStore();
+    }
+
     @Deactivate
     public void deactivate() {
         unregisterNodeStore();
@@ -151,21 +182,20 @@ public class SegmentNodeStoreFactory ext
     }
 
     private synchronized void registerNodeStore() throws IOException {
-        if (registerSegmentStore()) {
-
-            if (getRole() != null) {
-                registerNodeStoreProvider();
-                return;
-            }
-
+        if (registerSegmentStore() && role != null) {
+            registerNodeStoreProvider();
         }
     }
 
+    private boolean isSecondaryStoreMode() {
+        return "secondary".equals(role);
+    }
+
     private void registerNodeStoreProvider() {
         SegmentNodeStore.SegmentNodeStoreBuilder nodeStoreBuilder = 
SegmentNodeStore.builder(store);
         segmentNodeStore = nodeStoreBuilder.build();
         Dictionary<String, Object> props = new Hashtable<String, Object>();
-        props.put(NodeStoreProvider.ROLE, getRole());
+        props.put(NodeStoreProvider.ROLE, role);
         storeRegistration = 
context.getBundleContext().registerService(NodeStoreProvider.class.getName(), 
new NodeStoreProvider() {
                     @Override
                     public NodeStore getNodeStore() {
@@ -173,7 +203,7 @@ public class SegmentNodeStoreFactory ext
                     }
                 },
                 props);
-        log.info("Registered NodeStoreProvider backed by SegmentNodeStore of 
type '{}'", getRole());
+        log.info("Registered NodeStoreProvider backed by SegmentNodeStore of 
type '{}'", role);
     }
 
     private boolean registerSegmentStore() throws IOException {
@@ -192,6 +222,11 @@ public class SegmentNodeStoreFactory ext
                 .withMemoryMapping(getMode().equals("64"))
                 .withStatisticsProvider(statisticsProvider);
 
+        if (customBlobStore) {
+            log.info("Initializing SegmentNodeStore with BlobStore [{}]", 
blobStore);
+            builder.withBlobStore(blobStore);
+        }
+
         try {
             store = builder.build();
         } catch (InvalidFileStoreVersionException e) {
@@ -211,7 +246,7 @@ public class SegmentNodeStoreFactory ext
                 FileStoreStatsMBean.class,
                 store.getStats(),
                 FileStoreStatsMBean.TYPE,
-                "FileStore '" + getRole() + "' statistics"
+                "FileStore '" + role + "' statistics"
         );
 
         return true;
@@ -238,8 +273,11 @@ public class SegmentNodeStoreFactory ext
         if (directory != null) {
             return new File(directory);
         }
-
-        return new File("tarmk");
+        if (role == null) {
+            return new File("tarmk");
+        } else {
+            return new File("tarmk-" + role);
+        }
     }
 
     private File getDirectory() {
@@ -288,20 +326,10 @@ public class SegmentNodeStoreFactory ext
         return lookupConfigurationThenFramework(context, name);
     }
 
-    /**
-     * needed for situations where you have to unwrap the
-     * SegmentNodeStoreService, to get the SegmentStore, like the failover
-     */
-    @Override
-    public SegmentStore getSegmentStore() {
-        return store;
-    }
-
     //------------------------------------------------------------< Object >--
 
     @Override
     public String toString() {
-        return name + ": " + segmentNodeStore + "[role:" + getRole() + "]";
+        return name + ": " + segmentNodeStore + "[role:" + role + "]";
     }
-
-}
+}
\ No newline at end of file

Added: 
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactoryTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactoryTest.java?rev=1761799&view=auto
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactoryTest.java
 (added)
+++ 
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreFactoryTest.java
 Wed Sep 21 19:35:03 2016
@@ -0,0 +1,66 @@
+/*
+ * 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.spi.state.NodeStoreProvider;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static com.google.common.collect.Maps.newHashMap;
+import static org.apache.sling.testing.mock.osgi.MockOsgi.deactivate;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class SegmentNodeStoreFactoryTest extends SegmentNodeStoreServiceTest {
+
+    private SegmentNodeStoreFactory segmentNodeStoreFactory;
+
+    @Test
+    @Ignore
+    public void nodeStoreProvider() throws Exception {
+    }
+
+    @Override
+    protected void registerSegmentNodeStoreService(boolean customBlobStore) {
+        Map<String, Object> properties = newHashMap();
+
+        properties.put(SegmentNodeStoreFactory.ROLE, "some-role");
+        properties.put(SegmentNodeStoreFactory.CUSTOM_BLOB_STORE, 
customBlobStore);
+        properties.put(SegmentNodeStoreFactory.DIRECTORY, 
folder.getRoot().getAbsolutePath());
+
+        segmentNodeStoreFactory = context.registerInjectActivateService(new 
SegmentNodeStoreFactory(), properties);
+    }
+
+    @Override
+    protected void unregisterSegmentNodeStoreService() {
+        deactivate(segmentNodeStoreFactory);
+    }
+
+    @Override
+    protected void assertServiceActivated() {
+        assertNotNull(context.getService(NodeStoreProvider.class));
+    }
+
+    @Override
+    protected void assertServiceNotActivated() {
+        assertNull(context.getService(NodeStoreProvider.class));
+    }
+}
\ No newline at end of file

Modified: 
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java?rev=1761799&r1=1761798&r2=1761799&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-segment/src/test/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreServiceTest.java
 Wed Sep 21 19:35:03 2016
@@ -156,7 +156,7 @@ public class SegmentNodeStoreServiceTest
 
     private SegmentNodeStoreService segmentNodeStoreService;
 
-    private void registerSegmentNodeStoreService(boolean customBlobStore) {
+    protected void registerSegmentNodeStoreService(boolean customBlobStore) {
         Map<String, Object> properties = newHashMap();
 
         properties.put(SegmentNodeStoreService.CUSTOM_BLOB_STORE, 
customBlobStore);
@@ -165,7 +165,7 @@ public class SegmentNodeStoreServiceTest
         segmentNodeStoreService = context.registerInjectActivateService(new 
SegmentNodeStoreService(), properties);
     }
 
-    private void unregisterSegmentNodeStoreService() {
+    protected void unregisterSegmentNodeStoreService() {
         deactivate(segmentNodeStoreService);
     }
 
@@ -179,12 +179,12 @@ public class SegmentNodeStoreServiceTest
         blobStore.unregister();
     }
 
-    private void assertServiceActivated() {
+    protected void assertServiceActivated() {
         assertNotNull(context.getService(NodeStore.class));
         assertNotNull(context.getService(SegmentStoreProvider.class));
     }
 
-    private void assertServiceNotActivated() {
+    protected void assertServiceNotActivated() {
         assertNull(context.getService(NodeStore.class));
         assertNull(context.getService(SegmentStoreProvider.class));
     }


Reply via email to