You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2017/03/30 17:25:03 UTC
[34/73] [abbrv] lucene-solr:jira/solr-6203: SOLR-10304: Refactor new
SolrDocumentFetcher out of SolrIndexSearcher
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f1aef3d1/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java b/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
index fc50680..e41484f 100644
--- a/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
+++ b/solr/core/src/test/org/apache/solr/util/SolrPluginUtilsTest.java
@@ -16,38 +16,29 @@
*/
package org.apache.solr.util;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanClause.Occur;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.DisjunctionMaxQuery;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.QParser;
-import org.apache.solr.search.QueryCommand;
-import org.apache.solr.search.QueryResult;
import org.apache.solr.util.SolrPluginUtils.DisjunctionMaxQueryParser;
-import org.apache.solr.search.SolrIndexSearcher;
-import org.apache.solr.search.DocList;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.PhraseQuery;
-import org.apache.lucene.search.DisjunctionMaxQuery;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.BooleanClause.Occur;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashSet;
-
/**
* Tests that the functions in SolrPluginUtils work as advertised.
*/
@@ -59,52 +50,6 @@ public class SolrPluginUtilsTest extends SolrTestCaseJ4 {
}
@Test
- public void testDocListConversion() throws Exception {
- assertU("", adoc("id", "3234", "val_i", "1",
- "val_dynamic", "quick red fox"));
- assertU("", adoc("id", "3235", "val_i", "1",
- "val_dynamic", "quick green fox"));
- assertU("", adoc("id", "3236", "val_i", "1",
- "val_dynamic", "quick brown fox"));
- assertU("", commit());
-
- RefCounted<SolrIndexSearcher> holder = h.getCore().getSearcher();
- try {
- SolrIndexSearcher srchr = holder.get();
- QueryResult qr = new QueryResult();
- QueryCommand cmd = new QueryCommand();
- cmd.setQuery(new MatchAllDocsQuery());
- cmd.setLen(10);
- qr = srchr.search(qr, cmd);
-
- DocList docs = qr.getDocList();
- assertEquals("wrong docs size", 3, docs.size());
- Set<String> fields = new HashSet<>();
- fields.add("val_dynamic");
- fields.add("dynamic_val");
- fields.add("range_facet_l"); // copied from id
-
- SolrDocumentList list = SolrPluginUtils.docListToSolrDocumentList(docs, srchr, fields, null);
- assertEquals("wrong list Size", docs.size(), list.size());
- for (SolrDocument document : list) {
-
- assertTrue("unexpected field", ! document.containsKey("val_i"));
- assertTrue("unexpected id field", ! document.containsKey("id"));
-
- assertTrue("original field", document.containsKey("val_dynamic"));
- assertTrue("dyn copy field", document.containsKey("dynamic_val"));
- assertTrue("copy field", document.containsKey("range_facet_l"));
-
- assertNotNull("original field null", document.get("val_dynamic"));
- assertNotNull("dyn copy field null", document.get("dynamic_val"));
- assertNotNull("copy field null", document.get("range_facet_l"));
- }
- } finally {
- if (null != holder) holder.decref();
- }
- }
-
- @Test
public void testPartialEscape() {
assertEquals("",pe(""));