Apache Lucene open-source search software
SOLR-13656: fix bad mergePolicyFactory test in SolrIndexConfigTest
Munendra S N501a91763b65
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-mpf-solrconfig.xml b/solr/core/src/test-files/solr/collection1/conf/bad-mpf-solrconfig.xmlindex 189d4490fd3..19d786056ad 100644--- a/solr/core/src/test-files/solr/collection1/conf/bad-mpf-solrconfig.xml+++ b/solr/core/src/test-files/solr/collection1/conf/bad-mpf-solrconfig.xml@@ -24,7 +24,7 @@<luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion><indexConfig>- <mergePolicyFactory class="org.apache.solr.update.DummyMergePolicyFactory">+ <mergePolicyFactory class="org.apache.solr.index.DummyMergePolicyFactory"><int name="mergeFactor">8</int></mergePolicyFactory></indexConfig>diff --git a/solr/core/src/test/org/apache/solr/update/DummyMergePolicy.java b/solr/core/src/test/org/apache/solr/update/DummyMergePolicy.javadeleted file mode 100644index ed1b3ff6b07..00000000000--- a/solr/core/src/test/org/apache/solr/update/DummyMergePolicy.java+++ /dev/null@@ -1,33 +0,0 @@-/*- * 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.solr.update;--import org.apache.lucene.index.IndexWriter;-import org.apache.lucene.index.LogByteSizeMergePolicy;--/**- * Dummy implementation of {@link org.apache.lucene.index.MergePolicy} which doesn't have an empty constructor and- * is expected to fail if used within Solr- */-class DummyMergePolicy extends LogByteSizeMergePolicy {-- private DummyMergePolicy() {}-- public DummyMergePolicy(IndexWriter writer) {- super();- }-}diff --git a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.javaindex de5944edb45..b314293261f 100644--- a/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java+++ b/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java@@ -29,6 +29,7 @@ import org.apache.lucene.search.Sort;import org.apache.lucene.search.SortField;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.common.MapSerializable;+import org.apache.solr.common.SolrException;import org.apache.solr.core.DirectoryFactory;import org.apache.solr.core.SolrConfig;import org.apache.solr.core.TestMergePolicyConfig;@@ -60,17 +61,15 @@ public class SolrIndexConfigTest extends SolrTestCaseJ4 {private final Path instanceDir = TEST_PATH().resolve("collection1");@Test- public void testFailingSolrIndexConfigCreation() {- try {- SolrConfig solrConfig = new SolrConfig("bad-mpf-solrconfig.xml");- SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);- IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema(schemaFileName, solrConfig);- h.getCore().setLatestSchema(indexSchema);- solrIndexConfig.toIndexWriterConfig(h.getCore());- fail("a mergePolicy should have an empty constructor in order to be instantiated in Solr thus this should fail ");- } catch (Exception e) {- // it failed as expected- }+ public void testFailingSolrIndexConfigCreation() throws Exception {+ SolrConfig solrConfig = new SolrConfig(instanceDir,"bad-mpf-solrconfig.xml", null);+ SolrIndexConfig solrIndexConfig = new SolrIndexConfig(solrConfig, null, null);+ IndexSchema indexSchema = IndexSchemaFactory.buildIndexSchema(schemaFileName, solrConfig);+ h.getCore().setLatestSchema(indexSchema);++ // this should fail as mergePolicy doesn't have any public constructor+ SolrException ex = expectThrows(SolrException.class, () -> solrIndexConfig.toIndexWriterConfig(h.getCore()));+ assertTrue(ex.getMessage().contains("Error instantiating class: 'org.apache.solr.index.DummyMergePolicyFactory'"));}@Test