mirror of https://github.com/apache/lucene.git
SOLR-13656: fix bad mergePolicyFactory test in SolrIndexConfigTest
* use expectThrows to verify the exception and ex message * remove unused DummyMergePolicy
This commit is contained in:
parent
8566bcd25e
commit
501a91763b
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue