From b2698e5fcfc6ba3ef57162cf9f2cf5ba327a99a8 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Sun, 15 Mar 2015 20:06:22 +0000 Subject: [PATCH] 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 --- .../component/QueryElevationComponentTest.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java index 27bdd665f27..066399e53b2 100644 --- a/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java +++ b/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java @@ -534,7 +534,7 @@ public class QueryElevationComponentTest extends SolrTestCaseJ4 { String query = "title:ipod"; - Map args = new HashMap<>(); + Map 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']"