From dd0b36d053da597778387d02f005427c73cf022f Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 18 Apr 2013 16:10:46 +0000 Subject: [PATCH] make sure the test is run on a separate atomic readers git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1469397 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/search/join/TestBlockJoin.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java index 59abc56b5d9..0bb8abb5751 100644 --- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java +++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java @@ -63,9 +63,11 @@ public class TestBlockJoin extends LuceneTestCase { } public void testEmptyChildFilter() throws Exception { - final Directory dir = newDirectory(); - final RandomIndexWriter w = new RandomIndexWriter(random(), dir); + final IndexWriterConfig config = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); + config.setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES); + // we don't want to merge - since we rely on certain segment setup + final IndexWriter w = new IndexWriter(dir, config); final List docs = new ArrayList(); @@ -79,7 +81,6 @@ public class TestBlockJoin extends LuceneTestCase { docs.add(makeJob("java", 2006)); docs.add(makeResume("Frank", "United States")); w.addDocuments(docs); - w.commit(); int num = atLeast(10); // produce a segment that doesn't have a value in the docType field for (int i = 0; i < num; i++) { @@ -88,9 +89,10 @@ public class TestBlockJoin extends LuceneTestCase { w.addDocuments(docs); } - IndexReader r = w.getReader(); + IndexReader r = DirectoryReader.open(w, random().nextBoolean()); w.close(); - IndexSearcher s = newSearcher(r); + assertTrue(r.leaves().size() > 1); + IndexSearcher s = new IndexSearcher(r); Filter parentsFilter = new CachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("docType", "resume")))); BooleanQuery childQuery = new BooleanQuery();