mirror of https://github.com/apache/lucene.git
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:
parent
67d2e87fee
commit
c8de69bdce
|
@ -68,7 +68,6 @@ public class TestDirectoryReader extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
setUp();
|
|
||||||
doTestDocument();
|
doTestDocument();
|
||||||
doTestUndeleteAll();
|
doTestUndeleteAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,6 @@ public class FunctionTestSetup extends LuceneTestCaseJ4 {
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
// prepare a small index with just a few documents.
|
// prepare a small index with just a few documents.
|
||||||
super.setUp();
|
|
||||||
dir = new RAMDirectory();
|
dir = new RAMDirectory();
|
||||||
anlzr = new MockAnalyzer();
|
anlzr = new MockAnalyzer();
|
||||||
IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, anlzr));
|
IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, anlzr));
|
||||||
|
|
|
@ -72,6 +72,9 @@ public abstract class LuceneTestCase extends TestCase {
|
||||||
|
|
||||||
private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null;
|
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 {
|
private static class UncaughtExceptionEntry {
|
||||||
public final Thread thread;
|
public final Thread thread;
|
||||||
public final Throwable exception;
|
public final Throwable exception;
|
||||||
|
@ -94,7 +97,8 @@ public abstract class LuceneTestCase extends TestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup);
|
||||||
|
setup = true;
|
||||||
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
|
@ -128,6 +132,8 @@ public abstract class LuceneTestCase extends TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
assertTrue("ensure your setUp() calls super.setUp()!!!", setup);
|
||||||
|
setup = false;
|
||||||
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
|
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.lucene.search.FieldCache;
|
||||||
import org.apache.lucene.search.FieldCache.CacheEntry;
|
import org.apache.lucene.search.FieldCache.CacheEntry;
|
||||||
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
|
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -107,6 +108,9 @@ public class LuceneTestCaseJ4 {
|
||||||
|
|
||||||
private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null;
|
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 {
|
private static class UncaughtExceptionEntry {
|
||||||
public final Thread thread;
|
public final Thread thread;
|
||||||
public final Throwable exception;
|
public final Throwable exception;
|
||||||
|
@ -156,6 +160,8 @@ public class LuceneTestCaseJ4 {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
Assert.assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup);
|
||||||
|
setup = true;
|
||||||
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
|
@ -192,6 +198,8 @@ public class LuceneTestCaseJ4 {
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
|
Assert.assertTrue("ensure your setUp() calls super.setUp()!!!", setup);
|
||||||
|
setup = false;
|
||||||
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
|
BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue