SOLR-2552: make sure each test class starts/ends searcher tracking

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1128466 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-05-27 21:29:06 +00:00
parent cb9dfc11a1
commit 478414756e
2 changed files with 16 additions and 10 deletions

View File

@ -36,12 +36,8 @@ import org.apache.solr.handler.JsonUpdateRequestHandler;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.ResultContext;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.DocIterator;
import org.apache.solr.search.DocList;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.servlet.DirectSolrConnection;
import org.apache.solr.util.TestHarness;
@ -66,6 +62,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
@BeforeClass
public static void beforeClassSolrTestCase() throws Exception {
startTrackingSearchers();
ignoreException("ignore_exception");
}
@ -73,6 +70,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
public static void afterClassSolrTestCase() throws Exception {
deleteCore();
resetExceptionIgnores();
endTrackingSearchers();
}
@Override
@ -96,7 +94,6 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
/** Call initCore in @BeforeClass to instantiate a solr core in your test class.
* deleteCore will be called for you via SolrTestCaseJ4 @AfterClass */
public static void initCore(String config, String schema, String solrHome) throws Exception {
startTrackingSearchers();
configString = config;
schemaString = schema;
if (solrHome != null) {
@ -108,12 +105,12 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
static long numOpens;
static long numCloses;
protected static void startTrackingSearchers() {
public static void startTrackingSearchers() {
numOpens = SolrIndexSearcher.numOpens.get();
numCloses = SolrIndexSearcher.numCloses.get();
}
protected static void endTrackingSearchers() {
public static void endTrackingSearchers() {
long endNumOpens = SolrIndexSearcher.numOpens.get();
long endNumCloses = SolrIndexSearcher.numCloses.get();
@ -293,8 +290,6 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
h = null;
lrf = null;
configString = schemaString = null;
endTrackingSearchers();
}

View File

@ -28,7 +28,8 @@ import org.apache.solr.common.SolrInputField;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.XML;
import org.apache.solr.request.*;
import org.apache.solr.util.TestHarness;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.xml.sax.SAXException;
import org.slf4j.LoggerFactory;
@ -93,6 +94,16 @@ public abstract class AbstractSolrTestCase extends LuceneTestCase {
return SolrTestCaseJ4.TEST_HOME();
}
@BeforeClass
public static void beforeClassAbstractSolrTestCase() throws Exception {
SolrTestCaseJ4.startTrackingSearchers();
}
@AfterClass
public static void afterClassAbstractSolrTestCase() throws Exception {
SolrTestCaseJ4.endTrackingSearchers();
}
/**
* The directory used to story the index managed by the TestHarness h
*/