lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1066691 [2/2] - in /lucene/dev/trunk: lucene/contrib/highlighter/src/test/org/apache/lucene/search/highlight/ lucene/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/ lucene/contrib/queries/src/test/org/apache/lucene/sear...
Date Wed, 02 Feb 2011 23:27:29 GMT
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java Wed Feb  2 23:27:25 2011
@@ -53,7 +53,7 @@ public class TestMultiPhraseQuery extend
     add("piccadilly circus", writer);
     
     IndexReader reader = writer.getReader();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     // search for "blueberry pi*":
     MultiPhraseQuery query1 = new MultiPhraseQuery();
@@ -142,12 +142,13 @@ public class TestMultiPhraseQuery extend
     IndexReader r = writer.getReader();
     writer.close();
 
-    IndexSearcher searcher = new IndexSearcher(r);
+    IndexSearcher searcher = newSearcher(r);
     MultiPhraseQuery q = new MultiPhraseQuery();
     q.add(new Term("body", "blueberry"));
     q.add(new Term("body", "chocolate"));
     q.add(new Term[] {new Term("body", "pie"), new Term("body", "tart")});
     assertEquals(2, searcher.search(q, 1).totalHits);
+    searcher.close();
     r.close();
     indexStore.close();
   }
@@ -171,7 +172,7 @@ public class TestMultiPhraseQuery extend
     add("blue raspberry pie", writer);
     
     IndexReader reader = writer.getReader();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     // This query will be equivalent to +body:pie +body:"blue*"
     BooleanQuery q = new BooleanQuery();
     q.add(new TermQuery(new Term("body", "pie")), BooleanClause.Occur.MUST);
@@ -202,7 +203,7 @@ public class TestMultiPhraseQuery extend
     add("a note", "note", writer);
     
     IndexReader reader = writer.getReader();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     // This query will be equivalent to +type:note +body:"a t*"
     BooleanQuery q = new BooleanQuery();
@@ -229,7 +230,7 @@ public class TestMultiPhraseQuery extend
     add("a note", "note", writer);
     
     IndexReader reader = writer.getReader();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     MultiPhraseQuery q = new MultiPhraseQuery();
     q.add(new Term("body", "a"));
@@ -294,7 +295,7 @@ public class TestMultiPhraseQuery extend
     add("a note", "note", writer);
     
     IndexReader reader = writer.getReader();
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     searcher.setSimilarityProvider(new DefaultSimilarity() {
       
       @Override

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiTermConstantScore.java Wed Feb  2 23:27:25 2011
@@ -151,7 +151,7 @@ public class TestMultiTermConstantScore 
   public void testEqualScores() throws IOException {
     // NOTE: uses index build in *this* setUp
 
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     ScoreDoc[] result;
 
@@ -174,13 +174,14 @@ public class TestMultiTermConstantScore 
           result[i].score);
     }
 
+    search.close();
   }
 
   @Test
   public void testBoost() throws IOException {
     // NOTE: uses index build in *this* setUp
 
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     // test for correct application of query normalization
     // must use a non score normalizing method for this.
@@ -246,13 +247,14 @@ public class TestMultiTermConstantScore 
     Assert.assertEquals(0, hits[0].doc);
     Assert.assertEquals(1, hits[1].doc);
     assertTrue(hits[0].score > hits[1].score);
+    search.close();
   }
 
   @Test
   public void testBooleanOrderUnAffected() throws IOException {
     // NOTE: uses index build in *this* setUp
 
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     // first do a regular TermRangeQuery which uses term expansion so
     // docs with more terms in range get higher scores
@@ -277,6 +279,7 @@ public class TestMultiTermConstantScore 
           actual[i].doc);
     }
 
+    search.close();
   }
 
   @Test
@@ -284,7 +287,7 @@ public class TestMultiTermConstantScore 
     // NOTE: uses index build in *super* setUp
 
     IndexReader reader = signedIndexReader;
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     int medId = ((maxId - minId) / 2);
 
@@ -405,6 +408,8 @@ public class TestMultiTermConstantScore 
 
     result = search.search(csrq("id", medIP, medIP, T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, numDocs).scoreDocs;
     assertEquals("med,med,T,T", 1, result.length);
+    
+    search.close();
   }
 
   @Test
@@ -412,7 +417,7 @@ public class TestMultiTermConstantScore 
     // NOTE: uses index build in *super* setUp
 
     IndexReader reader = signedIndexReader;
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     int medId = ((maxId - minId) / 2);
 
@@ -489,6 +494,8 @@ public class TestMultiTermConstantScore 
 
     result = search.search(csrq("id", medIP, medIP, T, T, c), null, numDocs).scoreDocs;
     assertEquals("med,med,T,T,c", 1, result.length);
+    
+    search.close();
   }
 
   @Test
@@ -496,7 +503,7 @@ public class TestMultiTermConstantScore 
     // NOTE: uses index build in *super* setUp
 
     IndexReader reader = signedIndexReader;
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     String minRP = pad(signedIndexDir.minR);
     String maxRP = pad(signedIndexDir.maxR);
@@ -552,6 +559,7 @@ public class TestMultiTermConstantScore 
     result = search.search(csrq("rand", maxRP, null, T, F), null, numDocs).scoreDocs;
     assertEquals("max,nul,T,T", 1, result.length);
 
+    search.close();
   }
 
   @Test
@@ -560,7 +568,7 @@ public class TestMultiTermConstantScore 
 
     // using the unsigned index because collation seems to ignore hyphens
     IndexReader reader = unsignedIndexReader;
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     String minRP = pad(unsignedIndexDir.minR);
     String maxRP = pad(unsignedIndexDir.maxR);
@@ -617,6 +625,8 @@ public class TestMultiTermConstantScore 
     assertEquals("max,max,T,T,c", 1, result.length);
     result = search.search(csrq("rand", maxRP, null, T, F, c), null, numDocs).scoreDocs;
     assertEquals("max,nul,T,T,c", 1, result.length);
+    
+    search.close();
   }
 
   @Test
@@ -636,7 +646,7 @@ public class TestMultiTermConstantScore 
     IndexReader reader = writer.getReader();
     writer.close();
 
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     // Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
     // RuleBasedCollator. However, the Arabic Locale seems to order the Farsi
@@ -681,7 +691,7 @@ public class TestMultiTermConstantScore 
     IndexReader reader = writer.getReader();
     writer.close();
 
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
 
     Collator c = Collator.getInstance(new Locale("da", "dk"));
 

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiTermQueryRewrites.java Wed Feb  2 23:27:25 2011
@@ -61,17 +61,17 @@ public class TestMultiTermQueryRewrites 
     writer.close(); swriter1.close(); swriter2.close();
     
     reader = IndexReader.open(dir, true);
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     
     multiReader = new MultiReader(new IndexReader[] {
       IndexReader.open(sdir1, true), IndexReader.open(sdir2, true) 
     }, true);
-    multiSearcher = new IndexSearcher(multiReader);
+    multiSearcher = newSearcher(multiReader);
     
     multiReaderDupls = new MultiReader(new IndexReader[] {
       IndexReader.open(sdir1, true), IndexReader.open(dir, true) 
     }, true);
-    multiSearcherDupls = new IndexSearcher(multiReaderDupls);
+    multiSearcherDupls = newSearcher(multiReaderDupls);
   }
 
   @AfterClass

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java Wed Feb  2 23:27:25 2011
@@ -59,7 +59,7 @@ public class TestMultiValuedNumericRange
     IndexReader reader = writer.getReader();
     writer.close();
     
-    IndexSearcher searcher=new IndexSearcher(reader);
+    IndexSearcher searcher=newSearcher(reader);
     num = 50 * RANDOM_MULTIPLIER;
     for (int i = 0; i < num; i++) {
       int lower=random.nextInt(Integer.MAX_VALUE);

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNot.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNot.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNot.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNot.java Wed Feb  2 23:27:25 2011
@@ -44,7 +44,7 @@ public class TestNot extends LuceneTestC
     writer.addDocument(d1);
     IndexReader reader = writer.getReader();
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
       QueryParser parser = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer());
     Query query = parser.parse("a NOT b");
     //System.out.println(query);

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java Wed Feb  2 23:27:25 2011
@@ -89,7 +89,7 @@ public class TestNumericRangeQuery32 ext
     }
   
     reader = writer.getReader();
-    searcher=new IndexSearcher(reader);
+    searcher=newSearcher(reader);
     writer.close();
   }
   

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java Wed Feb  2 23:27:25 2011
@@ -89,7 +89,7 @@ public class TestNumericRangeQuery64 ext
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    searcher=new IndexSearcher(reader);
+    searcher=newSearcher(reader);
     writer.close();
   }
   

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java Wed Feb  2 23:27:25 2011
@@ -65,7 +65,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/trunk/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPhraseQuery.java Wed Feb  2 23:27:25 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();
 
-    IndexSearcher 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/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java Wed Feb  2 23:27:25 2011
@@ -96,7 +96,7 @@ public class TestPositionIncrement exten
     writer.close();
     
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     
     DocsAndPositionsEnum pos = MultiFields.getTermPositionsEnum(searcher.getIndexReader(),
                                                                 MultiFields.getDeletedDocs(searcher.getIndexReader()),
@@ -264,7 +264,7 @@ public class TestPositionIncrement exten
     // only one doc has "a"
     assertEquals(DocsAndPositionsEnum.NO_MORE_DOCS, tp.nextDoc());
 
-    IndexSearcher is = new IndexSearcher(readerFromWriter);
+    IndexSearcher is = newSearcher(readerFromWriter);
   
     SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
     SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java Wed Feb  2 23:27:25 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/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java Wed Feb  2 23:27:25 2011
@@ -48,7 +48,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/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java Wed Feb  2 23:27:25 2011
@@ -75,7 +75,7 @@ public class TestPrefixInBooleanQuery ex
     }
     
     reader = writer.getReader();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     writer.close();
   }
   

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java Wed Feb  2 23:27:25 2011
@@ -47,7 +47,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/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java Wed Feb  2 23:27:25 2011
@@ -65,7 +65,7 @@ public class TestPrefixRandom extends Lu
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     writer.close();
   }
 

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java Wed Feb  2 23:27:25 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/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java Wed Feb  2 23:27:25 2011
@@ -54,7 +54,7 @@ public class TestRegexpQuery extends Luc
     writer.addDocument(doc);
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   @Override

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java Wed Feb  2 23:27:25 2011
@@ -62,7 +62,7 @@ public class TestRegexpRandom extends Lu
     
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   private char N() {

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java Wed Feb  2 23:27:25 2011
@@ -82,7 +82,7 @@ public class TestRegexpRandom2 extends L
     }
     
     reader = writer.getReader();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     writer.close();
   }
 

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java Wed Feb  2 23:27:25 2011
@@ -104,7 +104,7 @@ public class TestScoreCachingWrappingSco
     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);
     ScoreCachingCollector scc = new ScoreCachingCollector(scores.length);

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSearchWithThreads.java Wed Feb  2 23:27:25 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/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarity.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarity.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarity.java Wed Feb  2 23:27:25 2011
@@ -80,7 +80,7 @@ public class TestSimilarity extends Luce
     IndexReader reader = writer.getReader();
     writer.close();
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = newSearcher(reader);
     searcher.setSimilarityProvider(new SimpleSimilarity());
 
     Term a = new Term("field", "a");

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSimilarityProvider.java Wed Feb  2 23:27:25 2011
@@ -56,7 +56,7 @@ public class TestSimilarityProvider exte
     iw.addDocument(doc);
     reader = iw.getReader();
     iw.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     searcher.setSimilarityProvider(sim);
   }
   

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSloppyPhraseQuery.java Wed Feb  2 23:27:25 2011
@@ -121,7 +121,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/trunk/lucene/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSort.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSort.java Wed Feb  2 23:27:25 2011
@@ -144,7 +144,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;
   }
@@ -1061,12 +1061,13 @@ public class TestSort extends LuceneTest
 
     IndexReader r = IndexReader.open(w, true);
     w.close();
-    IndexSearcher s = new IndexSearcher(r);
+    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();
   }
@@ -1105,10 +1106,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/trunk/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestSubScorerFreqs.java Wed Feb  2 23:27:25 2011
@@ -54,7 +54,7 @@ public class TestSubScorerFreqs extends 
       w.addDocument(doc);
     }
 
-    s = new IndexSearcher(w.getReader());
+    s = newSearcher(w.getReader());
     w.close();
   }
 

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermRangeFilter.java Wed Feb  2 23:27:25 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/trunk/lucene/src/test/org/apache/lucene/search/TestTermScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermScorer.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermScorer.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermScorer.java Wed Feb  2 23:27:25 2011
@@ -57,7 +57,7 @@ public class TestTermScorer extends Luce
     }
     indexReader = new SlowMultiReaderWrapper(writer.getReader());
     writer.close();
-    indexSearcher = new IndexSearcher(indexReader);
+    indexSearcher = newSearcher(indexReader);
   }
   
   @Override

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTermVectors.java Wed Feb  2 23:27:25 2011
@@ -71,7 +71,7 @@ public class TestTermVectors extends Luc
     }
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   @Override
@@ -246,7 +246,7 @@ public class TestTermVectors extends Luc
     writer.addDocument(testDoc4);
     IndexReader reader = writer.getReader();
     writer.close();
-    IndexSearcher knownSearcher = new IndexSearcher(reader);
+    IndexSearcher knownSearcher = newSearcher(reader);
     FieldsEnum fields = MultiFields.getFields(knownSearcher.reader).iterator();
     
     DocsEnum docs = null;
@@ -378,7 +378,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;
@@ -414,7 +414,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/trunk/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Wed Feb  2 23:27:25 2011
@@ -82,7 +82,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/trunk/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopDocsCollector.java Wed Feb  2 23:27:25 2011
@@ -95,7 +95,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/trunk/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestTopScoreDocCollector.java Wed Feb  2 23:27:25 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/trunk/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestWildcardRandom.java Wed Feb  2 23:27:25 2011
@@ -61,7 +61,7 @@ public class TestWildcardRandom extends 
     }
     
     reader = writer.getReader();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     writer.close();
   }
   

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/PayloadHelper.java Wed Feb  2 23:27:25 2011
@@ -25,6 +25,7 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.util.English;
+import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.SimilarityProvider;
@@ -129,7 +130,7 @@ public class PayloadHelper {
     reader = IndexReader.open(writer, true);
     writer.close();
 
-    IndexSearcher searcher = new IndexSearcher(reader);
+    IndexSearcher searcher = LuceneTestCase.newSearcher(reader);
     searcher.setSimilarityProvider(similarity);
     return searcher;
   }

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java Wed Feb  2 23:27:25 2011
@@ -117,7 +117,7 @@ public class TestPayloadNearQuery extend
     reader = writer.getReader();
     writer.close();
 
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     searcher.setSimilarityProvider(similarity);
   }
 

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java Wed Feb  2 23:27:25 2011
@@ -124,7 +124,7 @@ public class TestPayloadTermQuery extend
     reader = writer.getReader();
     writer.close();
 
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     searcher.setSimilarityProvider(similarity);
   }
 

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestBasics.java Wed Feb  2 23:27:25 2011
@@ -77,7 +77,7 @@ public class TestBasics extends LuceneTe
       writer.addDocument(doc);
     }
     reader = writer.getReader();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
     writer.close();
   }
 

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestFieldMaskingSpanQuery.java Wed Feb  2 23:27:25 2011
@@ -112,7 +112,7 @@ public class TestFieldMaskingSpanQuery e
                                          field("last",   "jones")     }));
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
 
   @Override

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java Wed Feb  2 23:27:25 2011
@@ -65,7 +65,7 @@ public class TestNearSpansOrdered extend
     }
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
 
   protected String[] docFields = {

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestPayloadSpans.java Wed Feb  2 23:27:25 2011
@@ -178,6 +178,7 @@ public class TestPayloadSpans extends Lu
     spans = MultiSpansWrapper.wrap(searcher.getTopReaderContext(), nestedSpanNearQuery);
     assertTrue("spans is null and it shouldn't be", spans != null);
     checkSpans(spans, 2, new int[]{3,3});
+    searcher.close();
     closeIndexReader.close();
     directory.close();
   }
@@ -210,6 +211,7 @@ public class TestPayloadSpans extends Lu
 
     assertTrue("spans is null and it shouldn't be", spans != null);
     checkSpans(spans, 1, new int[]{3});
+    searcher.close();
     closeIndexReader.close();
     directory.close();
   }
@@ -247,6 +249,7 @@ public class TestPayloadSpans extends Lu
     spans = MultiSpansWrapper.wrap(searcher.getTopReaderContext(), nestedSpanNearQuery);
     assertTrue("spans is null and it shouldn't be", spans != null);
     checkSpans(spans, 2, new int[]{8, 8});
+    searcher.close();
     closeIndexReader.close();
     directory.close();
   }
@@ -262,7 +265,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"));
@@ -285,6 +288,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();
   }
@@ -299,7 +303,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"));
@@ -321,6 +325,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();
   }
@@ -335,7 +340,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"));
@@ -363,6 +368,7 @@ public class TestPayloadSpans extends Lu
     }
     assertTrue(payloadSet.contains("a:Noise:10"));
     assertTrue(payloadSet.contains("k:Noise:11"));
+    is.close();
     reader.close();
     directory.close();
   }
@@ -378,7 +384,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.getTopReaderContext());
     
@@ -389,6 +395,7 @@ public class TestPayloadSpans extends Lu
       if(VERBOSE)
         System.out.println(new String(bytes));
     }
+    searcher.close();
     reader.close();
     directory.close();
   }
@@ -443,7 +450,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/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpanFirstQuery.java Wed Feb  2 23:27:25 2011
@@ -48,7 +48,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/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpanMultiTermQueryWrapper.java Wed Feb  2 23:27:25 2011
@@ -53,7 +53,7 @@ public class TestSpanMultiTermQueryWrapp
     iw.addDocument(doc);
     reader = iw.getReader();
     iw.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   @Override

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpans.java Wed Feb  2 23:27:25 2011
@@ -61,7 +61,7 @@ public class TestSpans extends LuceneTes
     }
     reader = writer.getReader();
     writer.close();
-    searcher = new IndexSearcher(reader);
+    searcher = newSearcher(reader);
   }
   
   @Override
@@ -486,7 +486,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"));
@@ -499,6 +499,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/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java Wed Feb  2 23:27:25 2011
@@ -66,7 +66,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/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java Wed Feb  2 23:27:25 2011
@@ -57,7 +57,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/trunk/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Wed Feb  2 23:27:25 2011
@@ -271,7 +271,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/trunk/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java Wed Feb  2 23:27:25 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/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java Wed Feb  2 23:27:25 2011
@@ -28,6 +28,9 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 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;
 
@@ -51,6 +54,7 @@ import org.apache.lucene.index.codecs.st
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.FieldCache;
 import org.apache.lucene.search.FieldCache.CacheEntry;
+import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.LockFactory;
@@ -564,14 +568,21 @@ public abstract class LuceneTestCase ext
           
         if (t.isAlive() && 
             !rogueThreads.containsKey(t) && 
-            t != Thread.currentThread()) {
+            t != Thread.currentThread() && 
+            /* 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);
@@ -1018,6 +1029,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.getTopReaderContext(), 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;

Modified: lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzerTest.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzerTest.java (original)
+++ lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzerTest.java Wed Feb  2 23:27:25 2011
@@ -76,7 +76,10 @@ public class QueryAutoStopWordAnalyzerTe
   private int search(Analyzer a, String queryString) throws IOException, ParseException {
     QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "repetitiveField", a);
     Query q = qp.parse(queryString);
-    return new IndexSearcher(reader).search(q, null, 1000).totalHits;
+    IndexSearcher searcher = newSearcher(reader);
+    int hits = searcher.search(q, null, 1000).totalHits;
+    searcher.close();
+    return hits;
   }
 
   public void testUninitializedAnalyzer() throws Exception {

Modified: lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/collation/CollationTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/collation/CollationTestBase.java?rev=1066691&r1=1066690&r2=1066691&view=diff
==============================================================================
--- lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/collation/CollationTestBase.java (original)
+++ lucene/dev/trunk/modules/analysis/common/src/test/org/apache/lucene/collation/CollationTestBase.java Wed Feb  2 23:27:25 2011
@@ -141,7 +141,7 @@ public abstract class CollationTestBase 
     writer.close();
 
     IndexReader reader = IndexReader.open(farsiIndex, true);
-    IndexSearcher search = new IndexSearcher(reader);
+    IndexSearcher search = newSearcher(reader);
         
     // Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
     // orders the U+0698 character before the U+0633 character, so the single



Mime
View raw message