You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2011/05/27 23:20:26 UTC

svn commit: r1128462 - in /lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr: SolrTestCaseJ4.java util/AbstractSolrTestCase.java

Author: mikemccand
Date: Fri May 27 21:20:26 2011
New Revision: 1128462

URL: http://svn.apache.org/viewvc?rev=1128462&view=rev
Log:
SOLR-2552: make sure each test class starts/ends searcher tracking

Modified:
    lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java
    lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java

Modified: lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java?rev=1128462&r1=1128461&r2=1128462&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/SolrTestCaseJ4.java Fri May 27 21:20:26 2011
@@ -62,6 +62,7 @@ public abstract class SolrTestCaseJ4 ext
 
   @BeforeClass
   public static void beforeClassSolrTestCase() throws Exception {
+    startTrackingSearchers();
     ignoreException("ignore_exception");
   }
 
@@ -69,6 +70,7 @@ public abstract class SolrTestCaseJ4 ext
   public static void afterClassSolrTestCase() throws Exception {
     deleteCore();
     resetExceptionIgnores();
+    endTrackingSearchers();
   }
 
   @Override
@@ -92,7 +94,6 @@ public abstract class SolrTestCaseJ4 ext
   /** 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) {
@@ -104,12 +105,12 @@ public abstract class SolrTestCaseJ4 ext
 
   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();
 
@@ -289,8 +290,6 @@ public abstract class SolrTestCaseJ4 ext
     h = null;
     lrf = null;
     configString = schemaString = null;
-
-    endTrackingSearchers();
   }
 
 

Modified: lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java?rev=1128462&r1=1128461&r2=1128462&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/test-framework/org/apache/solr/util/AbstractSolrTestCase.java Fri May 27 21:20:26 2011
@@ -27,7 +27,8 @@ import org.apache.solr.common.SolrInputD
 import org.apache.solr.common.SolrInputField;
 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;
@@ -92,6 +93,16 @@ public abstract class AbstractSolrTestCa
     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
    */