From de634b352683c310dea976fe39255a06ec932c66 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Sun, 21 Feb 2010 08:47:33 +0000 Subject: [PATCH] Save/Restore BQ.maxCluseCount in LuceneTestCase git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@912319 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/search/TestNumericRangeQuery32.java | 11 ++++++++--- .../apache/lucene/search/TestNumericRangeQuery64.java | 11 ++++++++--- src/test/org/apache/lucene/util/LuceneTestCase.java | 4 ++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java b/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java index caa4d6d16c8..68b96d88cef 100644 --- a/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java +++ b/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java @@ -42,9 +42,6 @@ public class TestNumericRangeQuery32 extends LuceneTestCase { private static final IndexSearcher searcher; static { try { - // set the theoretical maximum term count for 8bit (see docs for the number) - BooleanQuery.setMaxClauseCount(3*255*2 + 255); - directory = new RAMDirectory(); IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, MaxFieldLength.UNLIMITED); @@ -87,6 +84,14 @@ public class TestNumericRangeQuery32 extends LuceneTestCase { } } + @Override + public void setUp() throws Exception { + super.setUp(); + // set the theoretical maximum term count for 8bit (see docs for the number) + // super.tearDown will restore the default + BooleanQuery.setMaxClauseCount(3*255*2 + 255); + } + /** test for both constant score and boolean query, the other tests only use the constant score mode */ private void testRange(int precisionStep) throws Exception { String field="field"+precisionStep; diff --git a/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java b/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java index 263b2e04fa8..14f757aedc4 100644 --- a/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java +++ b/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java @@ -41,9 +41,6 @@ public class TestNumericRangeQuery64 extends LuceneTestCase { private static final IndexSearcher searcher; static { try { - // set the theoretical maximum term count for 8bit (see docs for the number) - BooleanQuery.setMaxClauseCount(7*255*2 + 255); - directory = new RAMDirectory(); IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(TEST_VERSION_CURRENT), true, MaxFieldLength.UNLIMITED); @@ -90,6 +87,14 @@ public class TestNumericRangeQuery64 extends LuceneTestCase { } } + @Override + public void setUp() throws Exception { + super.setUp(); + // set the theoretical maximum term count for 8bit (see docs for the number) + // super.tearDown will restore the default + BooleanQuery.setMaxClauseCount(7*255*2 + 255); + } + /** test for constant score + boolean query + filter, the other tests only use the constant score mode */ private void testRange(int precisionStep) throws Exception { String field="field"+precisionStep; diff --git a/src/test/org/apache/lucene/util/LuceneTestCase.java b/src/test/org/apache/lucene/util/LuceneTestCase.java index 593d2ffc1be..0abf2b9dd92 100644 --- a/src/test/org/apache/lucene/util/LuceneTestCase.java +++ b/src/test/org/apache/lucene/util/LuceneTestCase.java @@ -25,6 +25,7 @@ import java.util.Random; import junit.framework.TestCase; import org.apache.lucene.index.ConcurrentMergeScheduler; +import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldCache.CacheEntry; import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; @@ -54,6 +55,7 @@ import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; public abstract class LuceneTestCase extends TestCase { public static final Version TEST_VERSION_CURRENT = LuceneTestCaseJ4.TEST_VERSION_CURRENT; + private int savedBoolMaxClauseCount; public LuceneTestCase() { super(); @@ -67,6 +69,7 @@ public abstract class LuceneTestCase extends TestCase { protected void setUp() throws Exception { super.setUp(); ConcurrentMergeScheduler.setTestMode(); + savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount(); } /** @@ -89,6 +92,7 @@ public abstract class LuceneTestCase extends TestCase { @Override protected void tearDown() throws Exception { + BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount); try { // this isn't as useful as calling directly from the scope where the // index readers are used, because they could be gc'ed just before