You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2010/10/17 23:06:24 UTC

svn commit: r1023579 - in /lucene/dev/trunk/solr/src/test/org/apache/solr/spelling: DirectSolrSpellCheckerTest.java FileBasedSpellCheckerTest.java SpellCheckCollatorTest.java

Author: rmuir
Date: Sun Oct 17 21:06:24 2010
New Revision: 1023579

URL: http://svn.apache.org/viewvc?rev=1023579&view=rev
Log:
close up searchers in spellchecker tests

Modified:
    lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java?rev=1023579&r1=1023578&r2=1023579&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/DirectSolrSpellCheckerTest.java Sun Oct 17 21:06:24 2010
@@ -21,10 +21,11 @@ import java.util.Collection;
 import java.util.Map;
 
 import org.apache.lucene.analysis.Token;
-import org.apache.lucene.index.IndexReader;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.util.RefCounted;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -59,9 +60,9 @@ public class DirectSolrSpellCheckerTest 
     SolrCore core = h.getCore();
     checker.init(spellchecker, core);
 
-    IndexReader reader = core.getSearcher().get().getReader();
+    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     Collection<Token> tokens = queryConverter.convert("fob");
-    SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
+    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
     SpellingResult result = checker.getSuggestions(spellOpts);
     assertTrue("result is null and it shouldn't be", result != null);
     Map<String, Integer> suggestions = result.get(tokens.iterator().next());
@@ -74,5 +75,6 @@ public class DirectSolrSpellCheckerTest 
     assertTrue("result is null and it shouldn't be", result != null);
     suggestions = result.get(tokens.iterator().next());
     assertTrue("suggestions is not null and it should be", suggestions == null);
+    searcher.decref();
   }
 }

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java?rev=1023579&r1=1023578&r2=1023579&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/FileBasedSpellCheckerTest.java Sun Oct 17 21:06:24 2010
@@ -20,7 +20,8 @@ package org.apache.solr.spelling;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
-import org.apache.lucene.index.IndexReader;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.util.RefCounted;
 import org.apache.lucene.analysis.Token;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -78,9 +79,9 @@ public class FileBasedSpellCheckerTest e
     assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
     checker.build(core, null);
 
-    IndexReader reader = core.getSearcher().get().getReader();
+    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     Collection<Token> tokens = queryConverter.convert("fob");
-    SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
+    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
     SpellingResult result = checker.getSuggestions(spellOpts);
     assertTrue("result is null and it shouldn't be", result != null);
     Map<String, Integer> suggestions = result.get(tokens.iterator().next());
@@ -93,7 +94,7 @@ public class FileBasedSpellCheckerTest e
     assertTrue("result is null and it shouldn't be", result != null);
     suggestions = result.get(tokens.iterator().next());
     assertTrue("suggestions is not null and it should be", suggestions == null);
-
+    searcher.decref();
 
   }
 
@@ -117,10 +118,10 @@ public class FileBasedSpellCheckerTest e
     assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
     checker.build(core, null);
 
-    IndexReader reader = core.getSearcher().get().getReader();
+    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     Collection<Token> tokens = queryConverter.convert("Solar");
 
-    SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
+    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
     SpellingResult result = checker.getSuggestions(spellOpts);
     assertTrue("result is null and it shouldn't be", result != null);
     //should be lowercased, b/c we are using a lowercasing analyzer
@@ -136,6 +137,7 @@ public class FileBasedSpellCheckerTest e
     assertTrue("result is null and it shouldn't be", result != null);
     suggestions = result.get(tokens.iterator().next());
     assertTrue("suggestions is not null and it should be", suggestions == null);
+    searcher.decref();
   }
 
   /**
@@ -161,9 +163,9 @@ public class FileBasedSpellCheckerTest e
     assertTrue(dictName + " is not equal to " + "external", dictName.equals("external") == true);
     checker.build(core, null);
 
-    IndexReader reader = core.getSearcher().get().getReader();
+    RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     Collection<Token> tokens = queryConverter.convert("solar");
-    SpellingOptions spellOpts = new SpellingOptions(tokens, reader);
+    SpellingOptions spellOpts = new SpellingOptions(tokens, searcher.get().getReader());
     SpellingResult result = checker.getSuggestions(spellOpts);
     assertTrue("result is null and it shouldn't be", result != null);
     //should be lowercased, b/c we are using a lowercasing analyzer
@@ -179,5 +181,6 @@ public class FileBasedSpellCheckerTest e
     assertTrue("result is null and it shouldn't be", result != null);
     suggestions = result.get(spellOpts.tokens.iterator().next());
     assertTrue("suggestions is not null and it should be", suggestions == null);
+    searcher.decref();
   }
 }

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java?rev=1023579&r1=1023578&r2=1023579&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java Sun Oct 17 21:06:24 2010
@@ -33,6 +33,7 @@ import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.component.SearchComponent;
 import org.apache.solr.handler.component.SpellCheckComponent;
 import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestHandler;
 import org.apache.solr.response.SolrQueryResponse;
 import org.junit.BeforeClass;
@@ -73,7 +74,9 @@ public class SpellCheckCollatorTest exte
 		SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
 		SolrQueryResponse rsp = new SolrQueryResponse();
 		rsp.add("responseHeader", new SimpleOrderedMap());
-		handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+		SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
+		handler.handleRequest(req, rsp);
+		req.close();
 		NamedList values = rsp.getValues();
 		NamedList spellCheck = (NamedList) values.get("spellcheck");
 		NamedList suggestions = (NamedList) spellCheck.get("suggestions");