Save/Restore BQ.maxCluseCount in LuceneTestCase

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@912319 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2010-02-21 08:47:33 +00:00
parent fb789b04f4
commit de634b3526
3 changed files with 20 additions and 6 deletions

View File

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

View File

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

View File

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