tests: fix request reuse and request close bugs

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1666834 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2015-03-15 20:06:22 +00:00
parent f0cc3bfb00
commit b2698e5fcf
1 changed files with 11 additions and 3 deletions

View File

@ -534,7 +534,7 @@ public class QueryElevationComponentTest extends SolrTestCaseJ4 {
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 extends SolrTestCaseJ4 {
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 extends SolrTestCaseJ4 {
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 extends SolrTestCaseJ4 {
// 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 extends SolrTestCaseJ4 {
// 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 extends SolrTestCaseJ4 {
, "//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 extends SolrTestCaseJ4 {
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 extends SolrTestCaseJ4 {
//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 extends SolrTestCaseJ4 {
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 extends SolrTestCaseJ4 {
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 extends SolrTestCaseJ4 {
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']"