Apache Lucene open-source search software
SOLR-2002: assert inconsistencies in setup/teardown rather than giving an awkward IAE for maxclausecount=0
Robert Muirc8de69bdce9d
diff --git a/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java b/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.javaindex d347bcd67ea..d46d68d2c3b 100644--- a/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java+++ b/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java@@ -68,7 +68,6 @@ public class TestDirectoryReader extends LuceneTestCase {}public void test() throws Exception {- setUp();doTestDocument();doTestUndeleteAll();}diff --git a/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java b/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.javaindex 42feeb2cae4..34a12fcb107 100755--- a/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java+++ b/lucene/src/test/org/apache/lucene/search/function/FunctionTestSetup.java@@ -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));diff --git a/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test/org/apache/lucene/util/LuceneTestCase.javaindex e5d86f25a69..8a7bfff97cb 100644--- a/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java+++ b/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java@@ -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 {@Overrideprotected 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 {@Overrideprotected void tearDown() throws Exception {+ assertTrue("ensure your setUp() calls super.setUp()!!!", setup);+ setup = false;BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);try {diff --git a/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java b/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.javaindex 396c1b9e906..f4c04546927 100644--- a/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java+++ b/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java@@ -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 {@Beforepublic 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 {@Afterpublic void tearDown() throws Exception {+ Assert.assertTrue("ensure your setUp() calls super.setUp()!!!", setup);+ setup = false;BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);try {