Apache Lucene open-source search software
fix for SOLR-4317, don't requre 'collection1' in test harness. Thanks Tricia.
Erick Ericksonf5b524f434ef
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 9093d296788..c9f1c71b0d1 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -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 Componentsdiff --git a/solr/core/src/test-files/solr/solr-multicore.xml b/solr/core/src/test-files/solr/solr-multicore.xmlnew file mode 100644index 00000000000..abb308ec997--- /dev/null+++ b/solr/core/src/test-files/solr/solr-multicore.xml@@ -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>diff --git a/solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java b/solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.javanew file mode 100644index 00000000000..60f8abf96fe--- /dev/null+++ b/solr/core/src/test/org/apache/solr/SolrTestCaseJ4Test.java@@ -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());+ }+}diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.javaindex 050b4752967..5274aa04ef5 100755--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java@@ -384,7 +384,8 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {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.getRequestFactorydiff --git a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.javaindex 6c0146ce230..86d642c221c 100644--- a/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java+++ b/solr/test-framework/src/java/org/apache/solr/util/TestHarness.java@@ -87,6 +87,30 @@ public class TestHarness extends BaseTestHarness {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