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 2015/03/15 21:06:22 UTC

svn commit: r1666834 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java

Author: yonik
Date: Sun Mar 15 20:06:22 2015
New Revision: 1666834

URL: http://svn.apache.org/r1666834
Log:
tests: fix request reuse and request close bugs

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

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java?rev=1666834&r1=1666833&r2=1666834&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java Sun Mar 15 20:06:22 2015
@@ -534,7 +534,7 @@ public class QueryElevationComponentTest
 
       String query = "title:ipod";
 
-      Map<String, String> args = new HashMap<>();
+      Map<String, String> args = new HashMap<>();  // reusing args & requests this way is a solr-test-antipattern.  PLEASE DO NOT COPY THIS CODE
       args.put(CommonParams.Q, query);
       args.put(CommonParams.QT, "/elevate");
       args.put(CommonParams.FL, "id,score");
@@ -556,6 +556,7 @@ public class QueryElevationComponentTest
       booster.setTopQueryResults(reader, query, new String[]{"x", "y", "z"}, null);
 
 
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       assertQ("All six should make it", req
           , "//*[@numFound='6']"
           , "//result/doc[1]/str[@name='id'][.='x']"
@@ -569,6 +570,7 @@ public class QueryElevationComponentTest
       booster.elevationCache.clear();
 
       // now switch the order:
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       booster.setTopQueryResults(reader, query, new String[]{"a", "x"}, null);
       assertQ("All four should make it", req
           , "//*[@numFound='4']"
@@ -580,6 +582,7 @@ public class QueryElevationComponentTest
 
       // Test reverse sort
       args.put(CommonParams.SORT, "score asc");
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       assertQ("All four should make it", req
           , "//*[@numFound='4']"
           , "//result/doc[4]/str[@name='id'][.='a']"
@@ -592,6 +595,7 @@ public class QueryElevationComponentTest
       // default 'forceBoost' should be false
       assertEquals(false, booster.forceElevation);
       args.put(CommonParams.SORT, "str_s1 asc");
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       assertQ(null, req
           , "//*[@numFound='4']"
           , "//result/doc[1]/str[@name='id'][.='a']"
@@ -600,6 +604,7 @@ public class QueryElevationComponentTest
           , "//result/doc[4]/str[@name='id'][.='x']"
       );
       args.put(CommonParams.SORT, "id asc");
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       assertQ(null, req
           , "//*[@numFound='4']"
           , "//result/doc[1]/str[@name='id'][.='a']"
@@ -610,6 +615,7 @@ public class QueryElevationComponentTest
 
       booster.forceElevation = true;
       args.put(CommonParams.SORT, "id asc");
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       assertQ(null, req
           , "//*[@numFound='4']"
           , "//result/doc[1]/str[@name='id'][.='a']"
@@ -620,6 +626,7 @@ public class QueryElevationComponentTest
 
       //Test exclusive (not to be confused with exclusion)
       args.put(QueryElevationParams.EXCLUSIVE, "true");
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       booster.setTopQueryResults(reader, query, new String[]{"x", "a"}, new String[]{});
       assertQ(null, req
           , "//*[@numFound='2']"
@@ -631,6 +638,7 @@ public class QueryElevationComponentTest
       booster.elevationCache.clear();
       args.remove(CommonParams.SORT);
       args.remove(QueryElevationParams.EXCLUSIVE);
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       booster.setTopQueryResults(reader, query, new String[]{"x"}, new String[]{"a"});
       assertQ(null, req
           , "//*[@numFound='3']"
@@ -645,7 +653,7 @@ public class QueryElevationComponentTest
       booster.elevationCache.clear();
       args.put(QueryElevationParams.IDS, "x,y,z");
       args.put(QueryElevationParams.EXCLUDE, "b");
-
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       assertQ("All five should make it", req
           , "//*[@numFound='5']"
           , "//result/doc[1]/str[@name='id'][.='x']"
@@ -657,7 +665,7 @@ public class QueryElevationComponentTest
 
       args.put(QueryElevationParams.IDS, "x,z,y");
       args.put(QueryElevationParams.EXCLUDE, "b,c");
-
+      req.close(); req = new LocalSolrQueryRequest(h.getCore(), new MapSolrParams(args));
       assertQ("All four should make it", req
           , "//*[@numFound='4']"
           , "//result/doc[1]/str[@name='id'][.='x']"