Apache Lucene open-source search software
LUCENE-7006: increase BaseMergePolicyTestCase use (TestNoMergePolicy and TestSortingMergePolicy now extend it, TestUpgradeIndexMergePolicy added)
Christine Poerschkece0b931da890
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 017742da50d..db58f4d826c 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -266,6 +266,10 @@ Other* LUCENE-7005: TieredMergePolicy tweaks (>= vs. >, @see get vs. set)(Christine Poerschke)+* LUCENE-7006: increase BaseMergePolicyTestCase use (TestNoMergePolicy and+ TestSortingMergePolicy now extend it, TestUpgradeIndexMergePolicy added)+ (Christine Poerschke)+======================= Lucene 5.4.1 =======================Bug Fixesdiff --git a/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.javaindex e345ed489be..bdd83c6b19a 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java@@ -25,11 +25,15 @@ import java.util.Arrays;import org.apache.lucene.util.LuceneTestCase;import org.junit.Test;-public class TestNoMergePolicy extends LuceneTestCase {+public class TestNoMergePolicy extends BaseMergePolicyTestCase {++ public MergePolicy mergePolicy() {+ return NoMergePolicy.INSTANCE;+ }@Testpublic void testNoMergePolicy() throws Exception {- MergePolicy mp = NoMergePolicy.INSTANCE;+ MergePolicy mp = mergePolicy();assertNull(mp.findMerges(null, (SegmentInfos)null, null));assertNull(mp.findForcedMerges(null, 0, null, null));assertNull(mp.findForcedDeletesMerges(null, null));diff --git a/lucene/core/src/test/org/apache/lucene/index/TestUpgradeIndexMergePolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestUpgradeIndexMergePolicy.javanew file mode 100644index 00000000000..857bccadf19--- /dev/null+++ b/lucene/core/src/test/org/apache/lucene/index/TestUpgradeIndexMergePolicy.java@@ -0,0 +1,26 @@+package org.apache.lucene.index;++/*+ * 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.+ */++public class TestUpgradeIndexMergePolicy extends BaseMergePolicyTestCase {++ public MergePolicy mergePolicy() {+ return new UpgradeIndexMergePolicy(newMergePolicy(random()));+ }++}diff --git a/lucene/misc/src/test/org/apache/lucene/index/TestSortingMergePolicy.java b/lucene/misc/src/test/org/apache/lucene/index/TestSortingMergePolicy.javaindex 87291175865..d9baf551be6 100644--- a/lucene/misc/src/test/org/apache/lucene/index/TestSortingMergePolicy.java+++ b/lucene/misc/src/test/org/apache/lucene/index/TestSortingMergePolicy.java@@ -50,7 +50,7 @@ import org.apache.lucene.util.TestUtil;import com.carrotsearch.randomizedtesting.generators.RandomPicks;-public class TestSortingMergePolicy extends LuceneTestCase {+public class TestSortingMergePolicy extends BaseMergePolicyTestCase {private List<String> terms;private Directory dir1, dir2;@@ -78,6 +78,10 @@ public class TestSortingMergePolicy extends LuceneTestCase {return doc;}+ public MergePolicy mergePolicy() {+ return newSortingMergePolicy(sort);+ }+public static SortingMergePolicy newSortingMergePolicy(Sort sort) {// usually create a MP with a low merge factor so that many merges happenMergePolicy mp;@@ -113,7 +117,7 @@ public class TestSortingMergePolicy extends LuceneTestCase {final long seed = random().nextLong();final IndexWriterConfig iwc1 = newIndexWriterConfig(new MockAnalyzer(new Random(seed)));final IndexWriterConfig iwc2 = newIndexWriterConfig(new MockAnalyzer(new Random(seed)));- iwc2.setMergePolicy(newSortingMergePolicy(sort));+ iwc2.setMergePolicy(mergePolicy());final RandomIndexWriter iw1 = new RandomIndexWriter(new Random(seed), dir1, iwc1);final RandomIndexWriter iw2 = new RandomIndexWriter(new Random(seed), dir2, iwc2);for (int i = 0; i < numDocs; ++i) {