You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2010/10/15 01:50:42 UTC

svn commit: r1022768 - /lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java

Author: yonik
Date: Thu Oct 14 23:50:42 2010
New Revision: 1022768

URL: http://svn.apache.org/viewvc?rev=1022768&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=1022768&r1=1022767&r2=1022768&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 23:50:42 2010
@@ -98,80 +98,27 @@ public class SpellCheckComponentTest ext
     assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "q","documemt", SpellCheckComponent.SPELLCHECK_COLLATE, "true")
        ,"/spellcheck/suggestions/collation=='document'"
     );
-    assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "q","documemt lowerfilt:broen^4", SpellCheckComponent.SPELLCHECK_COLLATE, "true")
+    assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","documemt lowerfilt:broen^4", SpellCheckComponent.SPELLCHECK_COLLATE, "true")
        ,"/spellcheck/suggestions/collation=='document lowerfilt:brown^4'"
     );
-    assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_BUILD, "true", "q","documemtsss broens", SpellCheckComponent.SPELLCHECK_COLLATE, "true")
+    assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","documemtsss broens", SpellCheckComponent.SPELLCHECK_COLLATE, "true")
        ,"/spellcheck/suggestions/collation=='document brown'"
     );
+    assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","pixma-a-b-c-d-e-f-g", SpellCheckComponent.SPELLCHECK_COLLATE, "true")
+       ,"/spellcheck/suggestions/collation=='pixmaa'"
+    );
   }
   
-  @Test
-  public void testCollate2() 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, "pixma-a-b-c-d-e-f-g");
-    params.add(SpellCheckComponent.COMPONENT_NAME, "true");
-    params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");
-
-    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
-    SolrQueryResponse rsp = new SolrQueryResponse();
-    rsp.add("responseHeader", new SimpleOrderedMap());
-    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
-    NamedList values = rsp.getValues();
-    NamedList spellCheck = (NamedList) values.get("spellcheck");
-    NamedList suggestions = (NamedList) spellCheck.get("suggestions");
-    String collation = (String) suggestions.get("collation");
-    assertEquals("pixmaa", collation);
-  }
 
   @Test
   public void testCorrectSpelling() throws Exception {
-    SolrCore core = h.getCore();
-    Map<String, String> args = new HashMap<String, String>();
-
-    args.put(CommonParams.Q, "lowerfilt:lazy lowerfilt:brown");
-    args.put(CommonParams.QT, "spellCheckCompRH");
-    args.put(SpellCheckComponent.SPELLCHECK_BUILD, "true");
-    args.put(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true");
-    args.put(SpellCheckComponent.COMPONENT_NAME, "true");
-    SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(
-            args));
-
-    assertQ("Make sure correct spellings are signalled in the response", req, 
-            "//*[@numFound='1']", "//result/doc[1]/int[@name='id'][.='1']",
-            "//*/lst[@name='suggestions']");
-    
-    
-    args = new HashMap<String, String>();
-
-    args.put(CommonParams.Q, "lakkle");
-    args.put(CommonParams.QT, "spellCheckCompRH");
-    args.put(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true");
-    args.put(SpellCheckComponent.COMPONENT_NAME, "true");
-    req = new LocalSolrQueryRequest(core, new MapSolrParams(
-            args));
-    
-    assertQ("Make sure correct spellings are signalled in the response", req, 
-        "//*[@numFound='0']", "//*/lst[@name='suggestions']", "//*/bool[@name='correctlySpelled'][.='false']");
-    
-    
-    args = new HashMap<String, String>();
-
-    args.put(CommonParams.Q, "lowerfilt:lazy");
-    args.put(CommonParams.QT, "spellCheckCompRH");
-    args.put(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true");
-    args.put(SpellCheckComponent.COMPONENT_NAME, "true");
-    req = new LocalSolrQueryRequest(core, new MapSolrParams(
-            args));
-    
-    assertQ("Make sure correct spellings are signalled in the response", req, 
-        "//*[@numFound='1']", "//*/lst[@name='suggestions']", "//*/bool[@name='correctlySpelled'][.='true']");
+    // Make sure correct spellings are signaled in the response
+    assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","lowerfilt:lazy lowerfilt:brown", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true")
+       ,"/spellcheck/suggestions=={'correctlySpelled':true}"
+    );
+    assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","lakkle", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true")
+       ,"/spellcheck/suggestions/correctlySpelled==false"
+    );
   }
 
   @Test