SOLR-2002: assert inconsistencies in setup/teardown rather than giving an awkward IAE for maxclausecount=0

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@964459 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-07-15 15:10:37 +00:00
parent 67d2e87fee
commit c8de69bdce
4 changed files with 15 additions and 3 deletions

View File

@ -68,7 +68,6 @@ public class TestDirectoryReader extends LuceneTestCase {
}
public void test() throws Exception {
setUp();
doTestDocument();
doTestUndeleteAll();
}

View File

@ -93,7 +93,6 @@ public class FunctionTestSetup extends LuceneTestCaseJ4 {
public void setUp() throws Exception {
super.setUp();
// prepare a small index with just a few documents.
super.setUp();
dir = new RAMDirectory();
anlzr = new MockAnalyzer();
IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, anlzr));

View File

@ -72,6 +72,9 @@ public abstract class LuceneTestCase extends TestCase {
private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null;
/** Used to track if setUp and tearDown are called correctly from subclasses */
private boolean setup;
private static class UncaughtExceptionEntry {
public final Thread thread;
public final Throwable exception;
@ -94,7 +97,8 @@ public abstract class LuceneTestCase extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup);
setup = true;
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
@ -128,6 +132,8 @@ public abstract class LuceneTestCase extends TestCase {
@Override
protected void tearDown() throws Exception {
assertTrue("ensure your setUp() calls super.setUp()!!!", setup);
setup = false;
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
try {

View File

@ -23,6 +23,7 @@ import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.CacheEntry;
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -107,6 +108,9 @@ public class LuceneTestCaseJ4 {
private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null;
/** Used to track if setUp and tearDown are called correctly from subclasses */
private boolean setup;
private static class UncaughtExceptionEntry {
public final Thread thread;
public final Throwable exception;
@ -156,6 +160,8 @@ public class LuceneTestCaseJ4 {
@Before
public void setUp() throws Exception {
Assert.assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup);
setup = true;
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
@ -192,6 +198,8 @@ public class LuceneTestCaseJ4 {
@After
public void tearDown() throws Exception {
Assert.assertTrue("ensure your setUp() calls super.setUp()!!!", setup);
setup = false;
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
try {