jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1456065 - in /jackrabbit/oak/trunk: oak-solr-core/ oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/ oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/ oak-solr-core/src/test/java/org/a...
Date Wed, 13 Mar 2013 17:59:54 GMT
Author: tommaso
Date: Wed Mar 13 17:59:53 2013
New Revision: 1456065

URL: http://svn.apache.org/r1456065
Log:
OAK-699, OAK-684 - added DefaultOakSolrProvider with OakSolrNodeStateConfiguration to start
an EmbeddedSolrServer reading configuration from the node state, OakSolrConfiguration now
holds information about the core to be used

Added:
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultOakSolrProvider.java
  (with props)
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrNodeStateConfiguration.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-solr-core/pom.xml
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java
    jackrabbit/oak/trunk/oak-solr-remote/pom.xml
    jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java

Modified: jackrabbit/oak/trunk/oak-solr-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/pom.xml?rev=1456065&r1=1456064&r2=1456065&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-core/pom.xml Wed Mar 13 17:59:53 2013
@@ -45,12 +45,11 @@
               org.apache.jackrabbit.oak.plugins.index.solr,
               org.apache.jackrabbit.oak.plugins.index.solr.index,
               org.apache.jackrabbit.oak.plugins.index.solr.query,
-              org.apache.solr.*
+              org.apache.jackrabbit.oak.plugins.index.solr.server
             </Export-Package>
             <Private-Package>
               org.apache.jackrabbit.oak.plugins.index.solr.*
             </Private-Package>
-            <Embed-Dependency>solr-solrj</Embed-Dependency>
           </instructions>
         </configuration>
       </plugin>
@@ -104,6 +103,14 @@
       <groupId>org.apache.solr</groupId>
       <artifactId>solr-solrj</artifactId>
       <version>${solr.version}</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.solr</groupId>
+      <artifactId>solr-core</artifactId>
+      <version>${solr.version}</version>
+      <scope>provided</scope>
     </dependency>
 
     <!-- sorlj dependencies needed for OSGi deployments -->
@@ -183,13 +190,6 @@
     </dependency>
 
     <dependency>
-      <groupId>org.apache.solr</groupId>
-      <artifactId>solr-core</artifactId>
-      <version>${solr.version}</version>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>4.7</version>
@@ -219,6 +219,11 @@
       <optional>true</optional>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <version>1.9.5</version>
+    </dependency>
   </dependencies>
 
 </project>

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java?rev=1456065&r1=1456064&r2=1456065&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java
Wed Mar 13 17:59:53 2013
@@ -64,4 +64,12 @@ public interface OakSolrConfiguration {
      */
     public CommitPolicy getCommitPolicy();
 
+    /**
+     * Provide the name of the Solr core to be used
+     *
+     * @return a <code>String</code> representing the name of the Solr core to
+     *         be used fo Oak
+     */
+    public String getCoreName();
+
 }

Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultOakSolrProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultOakSolrProvider.java?rev=1456065&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultOakSolrProvider.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultOakSolrProvider.java
Wed Mar 13 17:59:53 2013
@@ -0,0 +1,62 @@
+/*
+ * 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.index.solr.server;
+
+import java.io.File;
+
+import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
+import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.SolrServerProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.core.CoreContainer;
+
+/**
+ * Default implementation of {@link SolrServerProvider} and {@link OakSolrConfigurationProvider}
+ * which hides an {@link EmbeddedSolrServer} configured as per passed {@link NodeState}
+ * properties.
+ */
+public class DefaultOakSolrProvider implements SolrServerProvider, OakSolrConfigurationProvider
{
+
+    private final OakSolrNodeStateConfiguration oakSolrConfiguration;
+
+    public DefaultOakSolrProvider(NodeState configurationNodeState) {
+        this.oakSolrConfiguration = new OakSolrNodeStateConfiguration(configurationNodeState);
+    }
+
+    private SolrServer solrServer;
+
+    private SolrServer createSolrServer() throws Exception {
+        CoreContainer coreContainer = new CoreContainer(oakSolrConfiguration.getSolrHomePath());
+        coreContainer.load(oakSolrConfiguration.getSolrHomePath(), new File(oakSolrConfiguration.getSolrConfigPath()));
+        return new EmbeddedSolrServer(coreContainer, oakSolrConfiguration.getCoreName());
+    }
+
+    @Override
+    public SolrServer getSolrServer() throws Exception {
+        if (solrServer == null) {
+            solrServer = createSolrServer();
+        }
+        return solrServer;
+    }
+
+    @Override
+    public OakSolrConfiguration getConfiguration() {
+        return oakSolrConfiguration;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultOakSolrProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrNodeStateConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrNodeStateConfiguration.java?rev=1456065&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrNodeStateConfiguration.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrNodeStateConfiguration.java
Wed Mar 13 17:59:53 2013
@@ -0,0 +1,122 @@
+/*
+ * 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.index.solr.server;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.plugins.index.solr.CommitPolicy;
+import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
+import org.apache.jackrabbit.oak.spi.query.Filter;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * An {@link OakSolrConfiguration} specified via a given {@link NodeState}.
+ * For each of the supported properties a default is provided if either the
+ * property doesn't exist in the node or if the value is <code>null</code> or
+ * empty <code>String</code>.
+ */
+public class OakSolrNodeStateConfiguration implements OakSolrConfiguration {
+
+    private NodeState solrConfigurationNodeState;
+
+    public OakSolrNodeStateConfiguration(NodeState solrConfigurationNodeState) {
+        this.solrConfigurationNodeState = solrConfigurationNodeState;
+    }
+
+    @Override
+    public String getFieldNameFor(Type<?> propertyType) {
+        return null;
+    }
+
+    @Override
+    public String getPathField() {
+        return getStringValueFor(Properties.PATH_FIELD, "path_exact");
+    }
+
+    @Override
+    public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction) {
+        String fieldName = null;
+        switch (pathRestriction) {
+            case ALL_CHILDREN: {
+                fieldName = getStringValueFor(Properties.DESCENDANTS_FIELD, "path_des");
+                break;
+            }
+            case DIRECT_CHILDREN: {
+                fieldName = getStringValueFor(Properties.CHILDREN_FIELD, "path_child");
+                break;
+            }
+            case EXACT: {
+                fieldName = getStringValueFor(Properties.PATH_FIELD, "path_exact");
+                break;
+            }
+            case PARENT: {
+                fieldName = getStringValueFor(Properties.PARENT_FIELD, "path_anc");
+                break;
+            }
+
+        }
+        return fieldName;
+    }
+
+    @Override
+    public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction)
{
+        return null;
+    }
+
+    @Override
+    public CommitPolicy getCommitPolicy() {
+        return CommitPolicy.valueOf(getStringValueFor(Properties.COMMIT_POLICY, CommitPolicy.HARD.toString()));
+    }
+
+    public String getSolrHomePath() {
+        return getStringValueFor(Properties.SOLRHOME_PATH, "./");
+    }
+
+    public String getSolrConfigPath() {
+        return getStringValueFor(Properties.SOLRCONFIG_PATH, "./solr.xml");
+    }
+
+    @Override
+    public String getCoreName() {
+        return getStringValueFor(Properties.CORE_NAME, "oak");
+    }
+
+    private String getStringValueFor(String propertyName, String defaultValue) {
+        String value = null;
+        PropertyState property = solrConfigurationNodeState.getProperty(propertyName);
+        if (property != null) {
+            value = property.getValue(Type.STRING);
+        }
+        if (value == null || value.length() == 0) {
+            value = defaultValue;
+        }
+        return value;
+    }
+
+    public final class Properties {
+
+        public static final String SOLRHOME_PATH = "solrHomePath";
+        public static final String SOLRCONFIG_PATH = "solrConfigPath";
+        public static final String CORE_NAME = "coreName";
+        public static final String PATH_FIELD = "pathField";
+        public static final String PARENT_FIELD = "parentField";
+        public static final String CHILDREN_FIELD = "childrenField";
+        public static final String DESCENDANTS_FIELD = "descendantsField";
+        public static final String COMMIT_POLICY = "commitPolicy";
+
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/OakSolrNodeStateConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java?rev=1456065&r1=1456064&r2=1456065&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java
Wed Mar 13 17:59:53 2013
@@ -41,7 +41,7 @@ public abstract class SolrBaseTest {
         store = new KernelNodeStore(microKernel);
         state = createInitialState(microKernel);
         server = TestUtils.createSolrServer();
-        configuration = TestUtils.getTestConfiguration();
+        configuration = TestUtils.getTestConfiguration(store.getRoot().getChildNode("solrIdx"));
     }
 
     @After
@@ -54,7 +54,10 @@ public abstract class SolrBaseTest {
     }
 
     protected NodeState createInitialState(MicroKernel microKernel) {
-        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{}";
+        String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{} " +
+                "+\"solrIdx\":{\"core\":\"oak\", \"solrHome\":\"" +
+                TestUtils.SOLR_HOME_PATH + "\", \"solrConfig\":\"" +
+                TestUtils.SOLRCONFIG_PATH + "\"} ";
         microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
         return store.getRoot();
     }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java?rev=1456065&r1=1456064&r2=1456065&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
Wed Mar 13 17:59:53 2013
@@ -21,14 +21,12 @@ import java.util.ArrayList;
 import java.util.List;
 import javax.annotation.Nonnull;
 
-import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.index.IndexDefinition;
 import org.apache.jackrabbit.oak.plugins.index.IndexHook;
 import org.apache.jackrabbit.oak.plugins.index.IndexHookProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
 import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexDiff;
 import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex;
-import org.apache.jackrabbit.oak.spi.query.Filter;
+import org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrNodeStateConfiguration;
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -46,57 +44,8 @@ import static org.apache.jackrabbit.oak.
  */
 public class TestUtils {
 
-    private static final String SOLR_HOME_PATH = "target/test-classes/solr";
-    private static final String SOLRCONFIG_PATH = "target/test-classes/solr/solr.xml";
-
-    public static OakSolrConfiguration getTestConfiguration() {
-        return new OakSolrConfiguration() {
-            @Override
-            public String getFieldNameFor(Type<?> propertyType) {
-                return null;
-            }
-
-            @Override
-            public String getPathField() {
-                return "path_exact";
-            }
-
-            @Override
-            public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction)
{
-                String fieldName = null;
-                switch (pathRestriction) {
-                    case ALL_CHILDREN: {
-                        fieldName = "path_des";
-                        break;
-                    }
-                    case DIRECT_CHILDREN: {
-                        fieldName = "path_child";
-                        break;
-                    }
-                    case EXACT: {
-                        fieldName = "path_exact";
-                        break;
-                    }
-                    case PARENT: {
-                        fieldName = "path_anc";
-                        break;
-                    }
-
-                }
-                return fieldName;
-            }
-
-            @Override
-            public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction)
{
-                return null;
-            }
-
-            @Override
-            public CommitPolicy getCommitPolicy() {
-                return CommitPolicy.HARD;
-            }
-        };
-    }
+    static final String SOLR_HOME_PATH = "target/test-classes/solr";
+    static final String SOLRCONFIG_PATH = "target/test-classes/solr/solr.xml";
 
     public static QueryIndexProvider getTestQueryIndexProvider(final SolrServer solrServer,
final OakSolrConfiguration configuration) {
         return new QueryIndexProvider() {
@@ -136,7 +85,6 @@ public class TestUtils {
 
     }
 
-
     public static SolrServer createSolrServer() throws Exception {
         CoreContainer coreContainer = new CoreContainer(SOLR_HOME_PATH);
         coreContainer.load(SOLR_HOME_PATH, new File(SOLRCONFIG_PATH));
@@ -144,4 +92,7 @@ public class TestUtils {
     }
 
 
+    public static OakSolrConfiguration getTestConfiguration(NodeState nodeState) {
+        return new OakSolrNodeStateConfiguration(nodeState);
+    }
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java?rev=1456065&r1=1456064&r2=1456065&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java
Wed Mar 13 17:59:53 2013
@@ -21,12 +21,14 @@ import java.util.Iterator;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex;
+import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
+import org.apache.jackrabbit.oak.plugins.index.solr.TestUtils;
+import org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrNodeStateConfiguration;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
 import org.apache.jackrabbit.oak.query.AbstractQueryTest;
 import org.apache.jackrabbit.oak.query.JsopUtil;
-import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
-import org.apache.jackrabbit.oak.plugins.index.solr.TestUtils;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.solr.client.solrj.SolrServer;
 import org.junit.After;
 import org.junit.Ignore;
@@ -35,6 +37,9 @@ import org.junit.Test;
 import static junit.framework.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 /**
  * General query extensive testcase for {@link org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex}
and {@link org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexDiff}
@@ -58,7 +63,8 @@ public class SolrIndexQueryTest extends 
 
     @Override
     protected ContentRepository createRepository() {
-        OakSolrConfiguration testConfiguration = TestUtils.getTestConfiguration();
+        NodeState mockedNodeState = createMockedConfigurationNodeState();
+        OakSolrConfiguration testConfiguration = TestUtils.getTestConfiguration(mockedNodeState);
         try {
             solrServer = TestUtils.createSolrServer();
             return new Oak().with(new InitialContent())
@@ -70,6 +76,20 @@ public class SolrIndexQueryTest extends 
         }
     }
 
+    private NodeState createMockedConfigurationNodeState() {
+        NodeState mockedNodeState = mock(NodeState.class);
+        when(mockedNodeState.getProperty(anyString())).thenReturn(null);
+//        when(mockedNodeState.getProperty(OakSolrNodeStateConfiguration.Properties.SOLRHOME_PATH)).
+//                thenReturn(PropertyStates.createProperty(OakSolrNodeStateConfiguration.Properties.SOLRHOME_PATH,
TestUtils.SOLR_HOME_PATH));
+//        when(mockedNodeState.getProperty(OakSolrNodeStateConfiguration.Properties.SOLRCONFIG_PATH)).
+//                thenReturn(PropertyStates.createProperty(OakSolrNodeStateConfiguration.Properties.SOLRCONFIG_PATH,
TestUtils.SOLRCONFIG_PATH));
+//        when(mockedNodeState.getProperty(OakSolrNodeStateConfiguration.Properties.PATH_FIELD)).
+//                thenReturn(PropertyStates.createProperty(OakSolrNodeStateConfiguration.Properties.PATH_FIELD,
"path_exact"));
+//        when(mockedNodeState.getProperty(OakSolrNodeStateConfiguration.Properties.COMMIT_POLICY)).
+//                thenReturn(PropertyStates.createProperty(OakSolrNodeStateConfiguration.Properties.COMMIT_POLICY,
"HARD"));
+        return mockedNodeState;
+    }
+
     @Test
     @Ignore("failing")
     public void sql2() throws Exception {

Modified: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java?rev=1456065&r1=1456064&r2=1456065&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java
Wed Mar 13 17:59:53 2013
@@ -81,4 +81,9 @@ public class EmbeddedSolrConfiguration i
     public CommitPolicy getCommitPolicy() {
         return CommitPolicy.SOFT;
     }
+
+    @Override
+    public String getCoreName() {
+        return "oak";
+    }
 }

Modified: jackrabbit/oak/trunk/oak-solr-remote/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-remote/pom.xml?rev=1456065&r1=1456064&r2=1456065&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-remote/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-remote/pom.xml Wed Mar 13 17:59:53 2013
@@ -90,6 +90,14 @@
       <artifactId>oak-solr-core</artifactId>
       <version>${project.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.solr</groupId>
+      <artifactId>solr-core</artifactId>
+      <version>${solr.version}</version>
+      <scope>provided</scope>
+    </dependency>
+
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.scr.annotations</artifactId>

Modified: jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java?rev=1456065&r1=1456064&r2=1456065&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java
Wed Mar 13 17:59:53 2013
@@ -42,6 +42,7 @@ public class RemoteSolrConfigurationProv
     private static final String DEFAULT_CHILD_FIELD = "path_child";
     private static final String DEFAULT_PARENT_FIELD = "path_anc";
     private static final String DEFAULT_PATH_FIELD = "path_exact";
+    private static final String DEFAULT_CORE_NAME = "oak";
 
     @Property(value = DEFAULT_DESC_FIELD)
     private static final String PATH_DESCENDANTS_FIELD = "path.desc.field";
@@ -55,10 +56,15 @@ public class RemoteSolrConfigurationProv
     @Property(value = DEFAULT_PATH_FIELD)
     private static final String PATH_EXACT_FIELD = "path.exact.field";
 
+    @Property(value = DEFAULT_CORE_NAME)
+    private static final String CORE_NAME = "core.name";
+
+
     private String pathChildrenFieldName;
     private String pathParentFieldName;
     private String pathDescendantsFieldName;
     private String pathExactFieldName;
+    private String coreName;
 
     private OakSolrConfiguration oakSolrConfiguration;
 
@@ -67,14 +73,17 @@ public class RemoteSolrConfigurationProv
         this.pathDescendantsFieldName = DEFAULT_DESC_FIELD;
         this.pathExactFieldName = DEFAULT_PATH_FIELD;
         this.pathParentFieldName = DEFAULT_PARENT_FIELD;
+        this.coreName = DEFAULT_CORE_NAME;
     }
 
     public RemoteSolrConfigurationProvider(String pathChildrenFieldName, String pathParentFieldName,
-                                           String pathDescendantsFieldName, String pathExactFieldName)
{
+                                           String pathDescendantsFieldName, String pathExactFieldName,
+                                           String coreName) {
         this.pathChildrenFieldName = pathChildrenFieldName;
         this.pathParentFieldName = pathParentFieldName;
         this.pathDescendantsFieldName = pathDescendantsFieldName;
         this.pathExactFieldName = pathExactFieldName;
+        this.coreName = coreName;
     }
 
     protected void activate(ComponentContext componentContext) throws Exception {
@@ -82,6 +91,7 @@ public class RemoteSolrConfigurationProv
         pathParentFieldName = String.valueOf(componentContext.getProperties().get(PATH_PARENT_FIELD));
         pathExactFieldName = String.valueOf(componentContext.getProperties().get(PATH_EXACT_FIELD));
         pathDescendantsFieldName = String.valueOf(componentContext.getProperties().get(PATH_DESCENDANTS_FIELD));
+        coreName = String.valueOf(componentContext.getProperties().get(CORE_NAME));
     }
 
     @Override
@@ -136,6 +146,11 @@ public class RemoteSolrConfigurationProv
                 public CommitPolicy getCommitPolicy() {
                     return CommitPolicy.SOFT;
                 }
+
+                 @Override
+                public String getCoreName() {
+                    return coreName;
+                }
             };
         }
         return oakSolrConfiguration;



Mime
View raw message