LUCENE-6753: defend against MockRandomMergePolicy

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1696808 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2015-08-20 15:44:23 +00:00
parent 0718e99f36
commit cd4e5dc2fc
1 changed files with 4 additions and 1 deletions

View File

@ -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);