From ad5ddee12ee87cff0f177409ba4ab58ff770830b Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Mon, 1 Feb 2016 17:51:09 +0000 Subject: [PATCH] LUCENE-7006: increase BaseMergePolicyTestCase use (TestNoMergePolicy and TestSortingMergePolicy now extend it, TestUpgradeIndexMergePolicy added) --- lucene/CHANGES.txt | 4 +++ .../lucene/index/TestNoMergePolicy.java | 8 ++++-- .../index/TestUpgradeIndexMergePolicy.java | 26 +++++++++++++++++++ .../lucene/index/TestSortingMergePolicy.java | 8 ++++-- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 lucene/core/src/test/org/apache/lucene/index/TestUpgradeIndexMergePolicy.java diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 0d4ce0a0001..d700a6f8e9e 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -160,6 +160,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 Fixes diff --git a/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java index 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; + } @Test public 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.java new file mode 100644 index 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.java index 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 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 happen MergePolicy 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) {