lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1066722 [2/2] - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/contrib/analyzers/common/src/test/org/apache/lucene/analysis/query/ lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/ lucene/contrib/instantiated/sr...
Date Thu, 03 Feb 2011 02:27:38 GMT
Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNot.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNot.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNot.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNot.java Thu Feb  3 02:27:35 2011
@@ -44,7 +44,7 @@ public class TestNot extends LuceneTestC
     writer.addDocument(d1);
     IndexReader reader = writer.getReader();
 
-    Searcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
       QueryParser parser = new QueryParser(TEST_VERSION_CURRENT, "field", new SimpleAnalyzer(TEST_VERSION_CURRENT));
     Query query = parser.parse("a NOT b");
     //System.out.println(query);

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java Thu Feb  3 02:27:35 2011
@@ -84,7 +84,7 @@ public class TestNumericRangeQuery32 ext
     }
   
     reader = writer.getReader();
-    searcher=new IndexSearcher(reader);
+    searcher=newSearcher(reader);
     writer.close();
   }
   

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java Thu Feb  3 02:27:35 2011
@@ -87,7 +87,7 @@ public class TestNumericRangeQuery64 ext
     }
   
     reader = writer.getReader();
-    searcher=new IndexSearcher(reader);
+    searcher=newSearcher(reader);
     writer.close();
   }
   

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java Thu Feb  3 02:27:35 2011
@@ -64,7 +64,7 @@ public class TestPhrasePrefixQuery exten
     IndexReader reader = writer.getReader();
     writer.close();
     
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     // PhrasePrefixQuery query1 = new PhrasePrefixQuery();
     MultiPhraseQuery query1 = new MultiPhraseQuery();

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java Thu Feb  3 02:27:35 2011
@@ -86,7 +86,7 @@ public class TestPhraseQuery extends Luc
     reader = writer.getReader();
     writer.close();
 
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     query = new PhraseQuery();
   }
 
@@ -221,7 +221,7 @@ public class TestPhraseQuery extends Luc
     IndexReader reader = writer.getReader();
     writer.close();
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
 
     // valid exact phrase query
     PhraseQuery query = new PhraseQuery();
@@ -262,7 +262,7 @@ public class TestPhraseQuery extends Luc
     IndexReader reader = writer.getReader();
     writer.close();
     
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     PhraseQuery phraseQuery = new PhraseQuery();
     phraseQuery.add(new Term("source", "marketing"));
@@ -301,7 +301,7 @@ public class TestPhraseQuery extends Luc
     reader = writer.getReader();
     writer.close();
     
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     
     termQuery = new TermQuery(new Term("contents","woo"));
     phraseQuery = new PhraseQuery();
@@ -352,7 +352,7 @@ public class TestPhraseQuery extends Luc
     IndexReader reader = writer.getReader();
     writer.close();
 
-    Searcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     PhraseQuery query = new PhraseQuery();
     query.add(new Term("field", "firstname"));
     query.add(new Term("field", "lastname"));
@@ -649,7 +649,7 @@ public class TestPhraseQuery extends Luc
     }
 
     IndexReader reader = w.getReader();
-    IndexSearcher s = new IndexSearcher(reader);
+    IndexSearcher s = newSearcher(reader);
     w.close();
 
     // now search

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java Thu Feb  3 02:27:35 2011
@@ -94,7 +94,7 @@ public class TestPositionIncrement exten
     writer.close();
     
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     TermPositions pos = searcher.getIndexReader().termPositions(new Term("field", "1"));
     pos.next();
@@ -262,7 +262,7 @@ public class TestPositionIncrement exten
     // only one doc has "a"
     assertFalse(tp.next());
 
-    IndexSearcher is = new IndexSearcher(r);
+    IndexSearcher is = newSearcher(r);
   
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
     SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java Thu Feb  3 02:27:35 2011
@@ -74,7 +74,7 @@ public class TestPositiveScoresOnlyColle
     writer.commit();
     IndexReader ir = writer.getReader();
     writer.close();
-    IndexSearcher searcher = new IndexSearcher(ir);
+    IndexSearcher searcher = newSearcher(ir);
     Weight fake = new TermQuery(new Term("fake", "weight")).createWeight(searcher);
     Scorer s = new SimpleScorer(fake);
     TopDocsCollector<ScoreDoc> tdc = TopScoreDocCollector.create(scores.length, true);

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java Thu Feb  3 02:27:35 2011
@@ -49,7 +49,7 @@ public class TestPrefixFilter extends Lu
     // PrefixFilter combined with ConstantScoreQuery
     PrefixFilter filter = new PrefixFilter(new Term("category", "/Computers"));
     Query query = new ConstantScoreQuery(filter);
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
     assertEquals(4, hits.length);
 

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java Thu Feb  3 02:27:35 2011
@@ -76,7 +76,7 @@ public class TestPrefixInBooleanQuery ex
     }
     
     reader = writer.getReader();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     writer.close();
   }
   

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java Thu Feb  3 02:27:35 2011
@@ -45,7 +45,7 @@ public class TestPrefixQuery extends Luc
     IndexReader reader = writer.getReader();
 
     PrefixQuery query = new PrefixQuery(new Term("category", "/Computers"));
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
     assertEquals("All documents in /Computers category and below", 3, hits.length);
 

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java Thu Feb  3 02:27:35 2011
@@ -43,7 +43,7 @@ public class TestQueryWrapperFilter exte
     // should not throw exception with primitive query
     QueryWrapperFilter qwf = new QueryWrapperFilter(termQuery);
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     TopDocs hits = searcher.search(new MatchAllDocsQuery(), qwf, 10);
     assertEquals(1, hits.totalHits);
     hits = searcher.search(new MatchAllDocsQuery(), new CachingWrapperFilter(qwf), 10);

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java Thu Feb  3 02:27:35 2011
@@ -63,7 +63,7 @@ public class TestSearchWithThreads exten
     final long endTime = System.currentTimeMillis();
     if (VERBOSE) System.out.println("BUILD took " + (endTime-startTime));
 
-    final IndexSearcher s = new IndexSearcher(r);
+    final IndexSearcher s = newSearcher(r);
 
     final AtomicBoolean failed = new AtomicBoolean();
     final AtomicLong netSearch = new AtomicLong();

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSimilarity.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSimilarity.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSimilarity.java Thu Feb  3 02:27:35 2011
@@ -76,7 +76,7 @@ public class TestSimilarity extends Luce
     IndexReader reader = writer.getReader();
     writer.close();
 
-    Searcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     searcher.setSimilarity(new SimpleSimilarity());
 
     Term a = new Term("field", "a");

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java Thu Feb  3 02:27:35 2011
@@ -120,7 +120,7 @@ public class TestSloppyPhraseQuery exten
 
     IndexReader reader = writer.getReader();
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     TopDocs td = searcher.search(query,null,10);
     //System.out.println("slop: "+slop+"  query: "+query+"  doc: "+doc+"  Expecting number of hits: "+expectedNumResults+" maxScore="+td.getMaxScore());
     assertEquals("slop: "+slop+"  query: "+query+"  doc: "+doc+"  Wrong number of hits", expectedNumResults, td.totalHits);

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java Thu Feb  3 02:27:35 2011
@@ -29,6 +29,7 @@ import java.util.concurrent.ExecutorServ
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -47,6 +48,7 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.DocIdBitSet;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;
+import org.junit.Ignore;
 
 /**
  * Unit tests for sorting code.
@@ -128,7 +130,7 @@ public class TestSort extends LuceneTest
     }
     IndexReader reader = writer.getReader();
     writer.close ();
-    IndexSearcher s = new IndexSearcher (reader);
+    IndexSearcher s = newSearcher(reader);
     s.setDefaultFieldSortScoring(true, true);
     return s;
   }
@@ -650,6 +652,7 @@ public class TestSort extends LuceneTest
 
   // test that the relevancy scores are the same even if
   // hits are sorted
+  @Ignore("Fix me! Fails if one of the subs is a threaded indexsearcher")
   public void testNormalizedScores() throws Exception {
 
     // capture relevancy scores
@@ -1097,6 +1100,32 @@ public class TestSort extends LuceneTest
     }
   }
 
+  public void testEmptyStringVsNullStringSort() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
+                        TEST_VERSION_CURRENT, new MockAnalyzer()));
+    Document doc = new Document();
+    doc.add(newField("f", "", Field.Store.NO, Field.Index.NOT_ANALYZED));
+    doc.add(newField("t", "1", Field.Store.NO, Field.Index.NOT_ANALYZED));
+    w.addDocument(doc);
+    w.commit();
+    doc = new Document();
+    doc.add(newField("t", "1", Field.Store.NO, Field.Index.NOT_ANALYZED));
+    w.addDocument(doc);
+
+    IndexReader r = IndexReader.open(w, true);
+    w.close();
+    IndexSearcher s = newSearcher(r);
+    TopDocs hits = s.search(new TermQuery(new Term("t", "1")), null, 10, new Sort(new SortField("f", SortField.STRING)));
+    assertEquals(2, hits.totalHits);
+    // null sorts first
+    assertEquals(1, hits.scoreDocs[0].doc);
+    assertEquals(0, hits.scoreDocs[1].doc);
+    s.close();
+    r.close();
+    dir.close();
+  }
+
   public void testLUCENE2142() throws IOException {
     Directory indexStore = newDirectory();
     IndexWriter writer = new IndexWriter(indexStore, newIndexWriterConfig(
@@ -1132,10 +1161,11 @@ public class TestSort extends LuceneTest
     IndexReader reader = writer.getReader();
     writer.close();
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     TotalHitCountCollector c = new TotalHitCountCollector();
     searcher.search(new MatchAllDocsQuery(), null, c);
     assertEquals(5, c.getTotalHits());
+    searcher.close();
     reader.close();
     indexStore.close();
   }

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java Thu Feb  3 02:27:35 2011
@@ -53,7 +53,7 @@ public class TestSubScorerFreqs extends 
       w.addDocument(doc);
     }
 
-    s = new IndexSearcher(w.getReader());
+    s = newSearcher(w.getReader());
     w.close();
   }
 

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java Thu Feb  3 02:27:35 2011
@@ -44,7 +44,7 @@ public class TestTermRangeFilter extends
   public void testRangeFilterId() throws IOException {
     
     IndexReader reader = signedIndexReader;
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
     
     int medId = ((maxId - minId) / 2);
     
@@ -141,13 +141,14 @@ public class TestTermRangeFilter extends
         numDocs).scoreDocs;
     assertEquals("med,med,T,T", 1, result.length);
     
+    search.close();
   }
   
   @Test
   public void testRangeFilterIdCollating() throws IOException {
     
     IndexReader reader = signedIndexReader;
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
     
     Collator c = Collator.getInstance(Locale.ENGLISH);
     
@@ -243,13 +244,15 @@ public class TestTermRangeFilter extends
     numHits = search.search(q,
         new TermRangeFilter("id", medIP, medIP, T, T, c), 1000).totalHits;
     assertEquals("med,med,T,T", 1, numHits);
+    
+    search.close();
   }
   
   @Test
   public void testRangeFilterRand() throws IOException {
     
     IndexReader reader = signedIndexReader;
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
     
     String minRP = pad(signedIndexDir.minR);
     String maxRP = pad(signedIndexDir.maxR);
@@ -320,6 +323,7 @@ public class TestTermRangeFilter extends
         numDocs).scoreDocs;
     assertEquals("max,nul,T,T", 1, result.length);
     
+    search.close();
   }
   
   @Test
@@ -327,7 +331,7 @@ public class TestTermRangeFilter extends
     
     // using the unsigned index because collation seems to ignore hyphens
     IndexReader reader = unsignedIndexReader;
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
     
     Collator c = Collator.getInstance(Locale.ENGLISH);
     
@@ -398,6 +402,8 @@ public class TestTermRangeFilter extends
     numHits = search.search(q,
         new TermRangeFilter("rand", maxRP, null, T, F, c), 1000).totalHits;
     assertEquals("max,nul,T,T", 1, numHits);
+    
+    search.close();
   }
   
   @Test
@@ -417,7 +423,7 @@ public class TestTermRangeFilter extends
     IndexReader reader = writer.getReader();
     writer.close();
     
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
     Query q = new TermQuery(new Term("body", "body"));
     
     // Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
@@ -461,7 +467,7 @@ public class TestTermRangeFilter extends
     IndexReader reader = writer.getReader();
     writer.close();
     
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
     Query q = new TermQuery(new Term("body", "body"));
     
     Collator collator = Collator.getInstance(new Locale("da", "dk"));

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermScorer.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermScorer.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermScorer.java Thu Feb  3 02:27:35 2011
@@ -54,7 +54,7 @@ public class TestTermScorer extends Luce
     writer.optimize();
     indexReader = writer.getReader();
     writer.close();
-    indexSearcher = new IndexSearcher(indexReader);
+    indexSearcher = newSearcher(indexReader);
   }
   
   @Override

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermVectors.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTermVectors.java Thu Feb  3 02:27:35 2011
@@ -66,7 +66,7 @@ public class TestTermVectors extends Luc
     }
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   @Override
@@ -245,7 +245,7 @@ public class TestTermVectors extends Luc
     writer.addDocument(testDoc4);
     IndexReader reader = writer.getReader();
     writer.close();
-    IndexSearcher knownSearcher = new IndexSearcher(reader);
+    IndexSearcher knownSearcher = newSearcher(reader);
     TermEnum termEnum = knownSearcher.reader.terms();
     TermDocs termDocs = knownSearcher.reader.termDocs();
     //System.out.println("Terms: " + termEnum.size() + " Orig Len: " + termArray.length);
@@ -379,7 +379,7 @@ public class TestTermVectors extends Luc
     }
     IndexReader reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
 
     Query query = new TermQuery(new Term("field", "hundred"));
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
@@ -415,7 +415,7 @@ public class TestTermVectors extends Luc
     IndexReader reader = writer.getReader();
     writer.close();
 
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
 
     Query query = new TermQuery(new Term("field", "one"));
     ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Thu Feb  3 02:27:35 2011
@@ -79,7 +79,7 @@ public class TestTimeLimitingCollector e
     }
     reader = iw.getReader();
     iw.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
 
     String qtxt = "one";
     // start from 1, so that the 0th doc never matches

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java Thu Feb  3 02:27:35 2011
@@ -94,7 +94,7 @@ public class TestTopDocsCollector extend
 
   private TopDocsCollector<ScoreDoc> doSearch(int numResults) throws IOException {
     Query q = new MatchAllDocsQuery();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     TopDocsCollector<ScoreDoc> tdc = new MyTopsDocCollector(numResults);
     searcher.search(q, tdc);
     searcher.close();

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java Thu Feb  3 02:27:35 2011
@@ -47,7 +47,7 @@ public class TestTopScoreDocCollector ex
     // the clause instead of BQ.
     bq.setMinimumNumberShouldMatch(1);
     IndexReader reader = writer.getReader();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     for (int i = 0; i < inOrder.length; i++) {
       TopDocsCollector<ScoreDoc> tdc = TopScoreDocCollector.create(3, inOrder[i]);
       assertEquals("org.apache.lucene.search.TopScoreDocCollector$" + actualTSDCClass[i], tdc.getClass().getName());

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java Thu Feb  3 02:27:35 2011
@@ -25,6 +25,7 @@ import org.apache.lucene.analysis.*;
 import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
@@ -127,7 +128,7 @@ public class PayloadHelper {
     reader = IndexReader.open(writer, true);
     writer.close();
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = LuceneTestCase.newSearcher(reader);
     searcher.setSimilarity(similarity);
     return searcher;
   }

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java Thu Feb  3 02:27:35 2011
@@ -118,7 +118,7 @@ public class TestPayloadNearQuery extend
     reader = writer.getReader();
     writer.close();
 
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     searcher.setSimilarity(similarity);
   }
 

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java Thu Feb  3 02:27:35 2011
@@ -124,7 +124,7 @@ public class TestPayloadTermQuery extend
     reader = writer.getReader();
     writer.close();
 
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     searcher.setSimilarity(similarity);
   }
 

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java Thu Feb  3 02:27:35 2011
@@ -76,7 +76,7 @@ public class TestBasics extends LuceneTe
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     writer.close();
   }
 

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java Thu Feb  3 02:27:35 2011
@@ -111,7 +111,7 @@ public class TestFieldMaskingSpanQuery e
                                          field("last",   "jones")     }));
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
 
   @Override

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java Thu Feb  3 02:27:35 2011
@@ -62,7 +62,7 @@ public class TestNearSpansOrdered extend
     }
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
 
   protected String[] docFields = {

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java Thu Feb  3 02:27:35 2011
@@ -177,6 +177,7 @@ public class TestPayloadSpans extends Lu
     spans = nestedSpanNearQuery.getSpans(searcher.getIndexReader());
     assertTrue("spans is null and it shouldn't be", spans != null);
     checkSpans(spans, 2, new int[]{3,3});
+    searcher.close();
     closeIndexReader.close();
     directory.close();
   }
@@ -209,6 +210,7 @@ public class TestPayloadSpans extends Lu
     spans = nestedSpanNearQuery.getSpans(searcher.getIndexReader());
     assertTrue("spans is null and it shouldn't be", spans != null);
     checkSpans(spans, 1, new int[]{3});
+    searcher.close();
     closeIndexReader.close();
     directory.close();
   }
@@ -246,6 +248,7 @@ public class TestPayloadSpans extends Lu
     spans = nestedSpanNearQuery.getSpans(searcher.getIndexReader());
     assertTrue("spans is null and it shouldn't be", spans != null);
     checkSpans(spans, 2, new int[]{8, 8});
+    searcher.close();
     closeIndexReader.close();
     directory.close();
   }
@@ -261,7 +264,7 @@ public class TestPayloadSpans extends Lu
     writer.addDocument(doc);
 
     IndexReader reader = writer.getReader();
-    IndexSearcher is = new IndexSearcher(reader);
+    IndexSearcher is = newSearcher(reader);
     writer.close();
 
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
@@ -284,6 +287,7 @@ public class TestPayloadSpans extends Lu
     assertEquals(2, payloadSet.size());
     assertTrue(payloadSet.contains("a:Noise:10"));
     assertTrue(payloadSet.contains("k:Noise:11"));
+    is.close();
     reader.close();
     directory.close();
   }
@@ -298,7 +302,7 @@ public class TestPayloadSpans extends Lu
     doc.add(new Field("content", new StringReader("a b a d k f a h i k a k")));
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
-    IndexSearcher is = new IndexSearcher(reader);
+    IndexSearcher is = newSearcher(reader);
     writer.close();
 
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
@@ -320,6 +324,7 @@ public class TestPayloadSpans extends Lu
     assertEquals(2, payloadSet.size());
     assertTrue(payloadSet.contains("a:Noise:10"));
     assertTrue(payloadSet.contains("k:Noise:11"));
+    is.close();
     reader.close();
     directory.close();
   }
@@ -334,7 +339,7 @@ public class TestPayloadSpans extends Lu
     doc.add(new Field("content", new StringReader("j k a l f k k p a t a k l k t a")));
     writer.addDocument(doc);
     IndexReader reader = writer.getReader();
-    IndexSearcher is = new IndexSearcher(reader);
+    IndexSearcher is = newSearcher(reader);
     writer.close();
 
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
@@ -362,6 +367,7 @@ public class TestPayloadSpans extends Lu
     }
     assertTrue(payloadSet.contains("a:Noise:10"));
     assertTrue(payloadSet.contains("k:Noise:11"));
+    is.close();
     reader.close();
     directory.close();
   }
@@ -377,7 +383,7 @@ public class TestPayloadSpans extends Lu
   
     IndexReader reader = writer.getReader();
     writer.close();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
 
     PayloadSpanUtil psu = new PayloadSpanUtil(searcher.getIndexReader());
     
@@ -388,6 +394,7 @@ public class TestPayloadSpans extends Lu
       if(VERBOSE)
         System.out.println(new String(bytes));
     }
+    searcher.close();
     reader.close();
     directory.close();
   }
@@ -442,7 +449,7 @@ public class TestPayloadSpans extends Lu
     closeIndexReader = writer.getReader();
     writer.close();
 
-    IndexSearcher searcher = new IndexSearcher(closeIndexReader);
+    IndexSearcher searcher = newSearcher(closeIndexReader);
     return searcher;
   }
   

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java Thu Feb  3 02:27:35 2011
@@ -44,7 +44,7 @@ public class TestSpanFirstQuery extends 
     writer.addDocument(doc2);
     
     IndexReader reader = writer.getReader();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     // user queries on "starts-with quick"
     SpanQuery sfq = new SpanFirstQuery(new SpanTermQuery(new Term("field", "quick")), 1);

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java Thu Feb  3 02:27:35 2011
@@ -54,7 +54,7 @@ public class TestSpanMultiTermQueryWrapp
     iw.addDocument(doc);
     reader = iw.getReader();
     iw.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   @Override

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java Thu Feb  3 02:27:35 2011
@@ -57,7 +57,7 @@ public class TestSpans extends LuceneTes
     }
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   @Override
@@ -473,7 +473,7 @@ public class TestSpans extends LuceneTes
 
     // Get searcher
     final IndexReader reader = IndexReader.open(dir, true);
-    final IndexSearcher searcher = new IndexSearcher(reader);
+    final IndexSearcher searcher = newSearcher(reader);
 
     // Control (make sure docs indexed)
     assertEquals(2, hitCount(searcher, "the"));
@@ -486,6 +486,7 @@ public class TestSpans extends LuceneTes
                  searcher.search(createSpan(0, true,                                 
                                             new SpanQuery[] {createSpan(4, false, "chased", "cat"),
                                                              createSpan("ate")}), 10).totalHits);
+    searcher.close();
     reader.close();
     dir.close();
   }

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java Thu Feb  3 02:27:35 2011
@@ -64,7 +64,7 @@ public class TestSpansAdvanced extends L
     addDocument(writer, "4", "I think it should work.");
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   @Override

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java Thu Feb  3 02:27:35 2011
@@ -54,7 +54,7 @@ public class TestSpansAdvanced2 extends 
     writer.close();
     
     // re-open the searcher since we added more docs
-    searcher2 = new IndexSearcher(reader2);
+    searcher2 = newSearcher(reader2);
   }
   
   @Override

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Thu Feb  3 02:27:35 2011
@@ -269,7 +269,7 @@ public class TestBufferedIndexInput exte
         assertEquals(reader.docFreq(bbb), 37);
         dir.tweakBufferSizes();
 
-        IndexSearcher searcher = new IndexSearcher(reader);
+        IndexSearcher searcher = newSearcher(reader);
         ScoreDoc[] hits = searcher.search(new TermQuery(bbb), null, 1000).scoreDocs;
         dir.tweakBufferSizes();
         assertEquals(35, hits.length);

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java Thu Feb  3 02:27:35 2011
@@ -82,7 +82,7 @@ public class TestRAMDirectory extends Lu
     assertEquals(docsToAdd, reader.numDocs());
     
     // open search zo check if all doc's are there
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     // search for all documents
     for (int i = 0; i < docsToAdd; i++) {

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=1066722&r1=1066721&r2=1066722&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java Thu Feb  3 02:27:35 2011
@@ -27,22 +27,18 @@ import java.lang.annotation.RetentionPol
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Random;
-import java.util.TimeZone;
-
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Field.Index;
 import org.apache.lucene.document.Field.Store;
 import org.apache.lucene.document.Field.TermVector;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.LogByteSizeMergePolicy;
 import org.apache.lucene.index.LogDocMergePolicy;
@@ -51,6 +47,7 @@ import org.apache.lucene.index.SerialMer
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.FieldCache.CacheEntry;
 import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.LockFactory;
@@ -442,14 +439,21 @@ public abstract class LuceneTestCase ext
             !rogueThreads.containsKey(t) && 
             t != Thread.currentThread() &&
             // TODO: TimeLimitingCollector starts a thread statically.... WTF?!
-            !t.getName().equals("TimeLimitedCollector timer thread")) {
+            !t.getName().equals("TimeLimitedCollector timer thread") &&
+            /* its ok to keep your searcher across test cases */
+            (t.getName().startsWith("LuceneTestCase") && context.startsWith("test method")) == false) {
           System.err.println("WARNING: " + context  + " left thread running: " + t);
           rogueThreads.put(t, true);
           rogueCount++;
-          // wait on the thread to die of natural causes
-          try {
-            t.join(THREAD_STOP_GRACE_MSEC);
-          } catch (InterruptedException e) { e.printStackTrace(); }
+          if (t.getName().startsWith("LuceneTestCase")) {
+            System.err.println("PLEASE CLOSE YOUR INDEXSEARCHERS IN YOUR TEST!!!!");
+            continue;
+          } else {
+            // wait on the thread to die of natural causes
+            try {
+              t.join(THREAD_STOP_GRACE_MSEC);
+            } catch (InterruptedException e) { e.printStackTrace(); }
+          }
           // try to stop the thread:
           t.setUncaughtExceptionHandler(null);
           Thread.setDefaultUncaughtExceptionHandler(null);
@@ -888,6 +892,34 @@ public abstract class LuceneTestCase ext
     } 
   }
   
+  /** create a new searcher over the reader */
+  public static IndexSearcher newSearcher(IndexReader r) throws IOException {
+    if (random.nextBoolean()) {
+      return new IndexSearcher(r);
+    } else {
+      int threads = 0;
+      final ExecutorService ex = (random.nextBoolean()) ? null 
+          : Executors.newFixedThreadPool(threads = _TestUtil.nextInt(random, 1, 8), 
+                      new NamedThreadFactory("LuceneTestCase"));
+      if (ex != null && VERBOSE) {
+        System.out.println("NOTE: newSearcher using ExecutorService with " + threads + " threads");
+      }
+      return new IndexSearcher(r, ex) {
+        @Override
+        public void close() throws IOException {
+          super.close();
+          if (ex != null) {
+            ex.shutdown();
+            try {
+              ex.awaitTermination(1000, TimeUnit.MILLISECONDS);
+            } catch (InterruptedException e) {
+              e.printStackTrace();
+            }
+          }
+        }
+      };
+    }
+  }
 
   public String getName() {
     return this.name;



Mime
View raw message