lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1022748 - /lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
Date Thu, 14 Oct 2010 22:49:21 GMT
Author: yonik
Date: Thu Oct 14 22:49:21 2010
New Revision: 1022748

URL: http://svn.apache.org/viewvc?rev=1022748&view=rev
Log:
tests: fix resource leaks and simplify

Modified:
    lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java?rev=1022748&r1=1022747&r2=1022748&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
(original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
Thu Oct 14 22:49:21 2010
@@ -43,6 +43,9 @@ import static org.junit.Assert.*;
  * @since solr 1.3
  */
 public class SpellCheckComponentTest extends SolrTestCaseJ4 {
+  static String rh = "spellCheckCompRH";
+
+
   @BeforeClass
   public static void beforeClass() throws Exception {
     initCore("solrconfig.xml","schema.xml");
@@ -77,7 +80,8 @@ public class SpellCheckComponentTest ext
     SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
     SolrQueryResponse rsp;
     rsp = new SolrQueryResponse();
-    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
+    handler.handleRequest(req, rsp);
     NamedList values = rsp.getValues();
     String cmdExec = (String) values.get("command");
     assertEquals("build",cmdExec);
@@ -89,6 +93,8 @@ public class SpellCheckComponentTest ext
     assertEquals(5,theSuggestion.size());
     //we know there are at least 5, but now only get 3
 
+    req.close();
+
     params.remove(SpellCheckComponent.SPELLCHECK_COUNT);
     params.remove(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS);
     params.remove(SpellCheckComponent.SPELLCHECK_BUILD);
@@ -115,35 +121,10 @@ public class SpellCheckComponentTest ext
 
   @Test
   public void test() throws Exception {
-    SolrCore core = h.getCore();
-    SearchComponent speller = core.getSearchComponent("spellcheck");
-    assertTrue("speller is null and it shouldn't be", speller != null);
-
-    ModifiableSolrParams params = new ModifiableSolrParams();
-    params.add(CommonParams.QT, "spellCheckCompRH");
-    params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
-    params.add(CommonParams.Q, "documemt");
-    params.add(SpellCheckComponent.COMPONENT_NAME, "true");
-
-    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
-    SolrQueryResponse rsp = new SolrQueryResponse();
-    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
-    NamedList values = rsp.getValues();
-    String cmdExec = (String) values.get("command");
-    assertTrue("command is null and it shouldn't be", cmdExec != null);
-    assertTrue(cmdExec + " is not equal to " + "build",
-            cmdExec.equals("build") == true);
-    NamedList spellCheck = (NamedList) values.get("spellcheck");
-    assertNotNull(spellCheck);
-    NamedList suggestions = (NamedList) spellCheck.get("suggestions");
-    assertNotNull(suggestions);
-    NamedList document = (NamedList) suggestions.get("documemt");
-    assertEquals(1, document.get("numFound"));
-    assertEquals(0, document.get("startOffset"));
-    assertEquals(document.get("endOffset"), "documemt".length());
-    Collection<String> theSuggestion = (Collection<String>) document.get("suggestion");
-    assertEquals(1, theSuggestion.size());
-    assertEquals("document", theSuggestion.iterator().next());
+    assertJQ(req("qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_BUILD,
"true", "q","documemt")
+       ,"/command=='build'"
+       ,"/spellcheck=={'suggestions':['documemt',{'numFound':1,'startOffset':0,'endOffset':8,'suggestion':['document']}]}"
+    );
   }
 
 



Mime
View raw message