lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1022755 - /lucene/dev/trunk/solr/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
Date Thu, 14 Oct 2010 23:01:51 GMT
Author: yonik
Date: Thu Oct 14 23:01:50 2010
New Revision: 1022755

URL: http://svn.apache.org/viewvc?rev=1022755&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=1022755&r1=1022754&r2=1022755&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:01:50 2010
@@ -66,57 +66,14 @@ public class SpellCheckComponentTest ext
   
   @Test
   public void testExtendedResultsCount() 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, "bluo");
-    params.add(SpellCheckComponent.COMPONENT_NAME, "true");
-    params.add(SpellCheckComponent.SPELLCHECK_COUNT, String.valueOf(5));
-    params.add(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, String.valueOf(false));
-    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
-    SolrQueryResponse rsp;
-    rsp = new SolrQueryResponse();
-    SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
-    handler.handleRequest(req, rsp);
-    NamedList values = rsp.getValues();
-    String cmdExec = (String) values.get("command");
-    assertEquals("build",cmdExec);
-    NamedList spellCheck = (NamedList) values.get("spellcheck");
-    NamedList suggestions = (NamedList) spellCheck.get("suggestions");
-    NamedList blue = (NamedList) suggestions.get("bluo");
-    assertEquals(5,blue.get("numFound"));
-    Collection<String> theSuggestion = (Collection<String>) blue.get("suggestion");
-    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);
-    params.add(SpellCheckComponent.SPELLCHECK_COUNT, "3");
-    params.add(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, String.valueOf(true));
-    params.add(SpellCheckComponent.SPELLCHECK_BUILD, "false");
-    rsp = new SolrQueryResponse();
-    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
-    values = rsp.getValues();
-
-    spellCheck = (NamedList) values.get("spellcheck");
-    suggestions = (NamedList) spellCheck.get("suggestions");
-    blue = (NamedList) suggestions.get("bluo");
-    assertEquals(3, blue.get("numFound"));
-
-    List<SimpleOrderedMap> theSuggestions = (List<SimpleOrderedMap>)blue.get("suggestion");
-    assertEquals(3, theSuggestions.size());
+    assertJQ(req("qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", SpellCheckComponent.SPELLCHECK_BUILD,
"true", "q","bluo", SpellCheckComponent.SPELLCHECK_COUNT,"5", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS,"false")
+       ,"/spellcheck/suggestions/[0]=='bluo'"
+       ,"/spellcheck/suggestions/[1]/numFound==5"
+    );
 
-    for (SimpleOrderedMap sug : theSuggestions) {
-      assertNotNull(sug.get("word"));
-      assertNotNull(sug.get("freq"));      
-    }
+    assertJQ(req("qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","bluo", SpellCheckComponent.SPELLCHECK_COUNT,"3",
SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS,"true")
+       ,"/spellcheck/suggestions/[1]/suggestion==[{'word':'blue','freq':1}, {'word':'blud','freq':1},
{'word':'boue','freq':1}]"
+    );
   }
 
   @Test



Mime
View raw message