You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2013/03/11 16:46:53 UTC

svn commit: r1455196 - in /lucene/dev/trunk/solr: ./ core/src/test-files/solr/ core/src/test/org/apache/solr/ test-framework/src/java/org/apache/solr/ test-framework/src/java/org/apache/solr/util/

Author: erick
Date: Mon Mar 11 15:46:52 2013
New Revision: 1455196

URL: http://svn.apache.org/r1455196
Log:
fix for SOLR-4317, don't requre 'collection1' in test harness. Thanks Tricia.

Added:
    lucene/dev/trunk/solr/core/src/test-files/solr/solr-multicore.xml   (with props)
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java   (with props)
Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
    lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1455196&r1=1455195&r2=1455196&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Mon Mar 11 15:46:52 2013
@@ -76,6 +76,8 @@ Other Changes
 
 * SOLR-4537: Clean up schema information REST API. (Steve Rowe)
 
+* SOLR-4317: SolrTestCaseJ4: Can't avoid "collection1" convention (Tricia Jenkins, via Erick Erickson)
+
 ==================  4.2.0 ==================
 
 Versions of Major Components

Added: lucene/dev/trunk/solr/core/src/test-files/solr/solr-multicore.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/solr-multicore.xml?rev=1455196&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/solr-multicore.xml (added)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/solr-multicore.xml Mon Mar 11 15:46:52 2013
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+
+<!--
+ All (relative) paths are relative to the installation path
+
+  persistent: Save changes made via the API to this file
+  sharedLib: path to a lib directory that will be shared across all cores
+-->
+<solr persistent="false">
+
+  <!--
+  adminPath: RequestHandler path to manage cores.
+    If 'null' (or absent), cores will not be manageable via request handler
+  -->
+  <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:}">
+    <core name="core0" instanceDir="core0" />
+    <core name="core1" instanceDir="core1" />
+  </cores>
+</solr>
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+
+<!--
+ All (relative) paths are relative to the installation path
+
+  persistent: Save changes made via the API to this file
+  sharedLib: path to a lib directory that will be shared across all cores
+-->
+<solr persistent="false">
+
+  <!--
+  adminPath: RequestHandler path to manage cores.
+    If 'null' (or absent), cores will not be manageable via request handler
+  -->
+  <cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:}">
+    <core name="core0" instanceDir="core0" />
+    <core name="core1" instanceDir="core1" />
+  </cores>
+</solr>

Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java?rev=1455196&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java (added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java Mon Mar 11 15:46:52 2013
@@ -0,0 +1,62 @@
+package org.apache.solr;
+
+/*
+ * 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.
+ */
+
+import org.apache.commons.io.FileUtils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+
+
+public class SolrTestCaseJ4Test extends SolrTestCaseJ4 {
+
+  private static String tmpSolrHome;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+
+    // Create a temporary directory that holds a core NOT named "collection1". Use the smallest configuration sets
+    // we can so we don't copy that much junk around.
+    createTempDir();
+    tmpSolrHome = TEMP_DIR + File.separator + SolrTestCaseJ4Test.class.getSimpleName() + System.currentTimeMillis();
+
+    File subHome = new File(new File(tmpSolrHome, "core0"), "conf");
+    assertTrue("Failed to make subdirectory ", subHome.mkdirs());
+    String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
+    FileUtils.copyFile(new File(top, "schema-tiny.xml"), new File(subHome, "schema-tiny.xml"));
+    FileUtils.copyFile(new File(top, "solrconfig-minimal.xml"), new File(subHome, "solrconfig-minimal.xml"));
+
+    FileUtils.copyDirectory(new File(tmpSolrHome, "core0"), new File(tmpSolrHome, "core1"));
+
+    FileUtils.copyFile(getFile("solr/solr-multicore.xml"), new File(tmpSolrHome, "solr.xml"));
+
+    initCore("solrconfig-minimal.xml", "schema-tiny.xml", tmpSolrHome, "core1");
+  }
+
+  @AfterClass
+  public static void AfterClass() throws Exception {
+    FileUtils.deleteDirectory(new File(tmpSolrHome).getAbsoluteFile());
+  }
+
+  @Test
+  public void testCorrectCore() throws Exception {
+    assertEquals("should be core1", "core1", h.getCore().getName());
+  }
+}

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1455196&r1=1455195&r2=1455196&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java Mon Mar 11 15:46:52 2013
@@ -384,7 +384,8 @@ public abstract class SolrTestCaseJ4 ext
   public static void createCore() {
     assertNotNull(testSolrHome);
     solrConfig = TestHarness.createConfig(testSolrHome, coreName, getSolrConfigFile());
-    h = new TestHarness( dataDir.getAbsolutePath(),
+    h = new TestHarness( coreName,
+            dataDir.getAbsolutePath(),
             solrConfig,
             getSchemaFile());
     lrf = h.getRequestFactory

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java?rev=1455196&r1=1455195&r2=1455196&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java Mon Mar 11 15:46:52 2013
@@ -87,6 +87,30 @@ public class TestHarness extends BaseTes
     return createConfig(solrHome, CoreContainer.DEFAULT_DEFAULT_CORE_NAME, confFile);
   }
 
+  /**
+   * @param coreName to initialize
+   * @param dataDirectory path for index data, will not be cleaned up
+   * @param solrConfig solronfig instance
+   * @param schemaFile schema filename
+   */
+     public TestHarness( String coreName,
+                         String dataDirectory,
+                         SolrConfig solrConfig,
+                         String schemaFile) {
+    this( coreName, dataDirectory, solrConfig, new IndexSchema(solrConfig, schemaFile, null));
+  } 
+  /**
+   * @param coreName to initialize
+   * @param dataDirectory path for index data, will not be cleaned up
+   * @param solrConfig solrconfig instance
+   * @param indexSchema schema instance
+   */
+    public TestHarness( String coreName,
+                        String dataDirectory,
+                        SolrConfig solrConfig,
+                        IndexSchema indexSchema) {
+        this(coreName, new Initializer(coreName, dataDirectory, solrConfig, indexSchema));
+    }
    /**
     * @param dataDirectory path for index data, will not be cleaned up
     * @param solrConfig solronfig instance