From cd4e5dc2fc35e90c640a7ff097cb90b740d9d29e Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 20 Aug 2015 15:44:23 +0000 Subject: [PATCH] LUCENE-6753: defend against MockRandomMergePolicy git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1696808 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/search/similarities/TestSimilarity2.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java b/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java index 3b5d970c688..4e493084881 100644 --- a/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java +++ b/lucene/core/src/test/org/apache/lucene/search/similarities/TestSimilarity2.java @@ -26,6 +26,7 @@ import org.apache.lucene.document.FieldType; import org.apache.lucene.document.TextField; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.BooleanClause; @@ -165,7 +166,9 @@ public class TestSimilarity2 extends LuceneTestCase { /** make sure scores are not skewed by docs not containing the field */ public void testNoFieldSkew() throws Exception { Directory dir = newDirectory(); - RandomIndexWriter iw = new RandomIndexWriter(random(), dir); + // an evil merge policy could reorder our docs for no reason + IndexWriterConfig iwConfig = newIndexWriterConfig().setMergePolicy(newLogMergePolicy()); + RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwConfig); Document doc = new Document(); doc.add(newTextField("foo", "bar baz somethingelse", Field.Store.NO)); iw.addDocument(doc);