Skip to content

Apache Lucene open-source search software

LUCENE-6609: refactor Solr tests to isolate SortedSetSelector dependent code into a test that SuppressCodecs the problematic docvalues formats

Chris M. Hostetter4ceb26a3ce00
diff --git a/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java b/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java
index 1a88cc40c03..3d12b44297c 100644
--- a/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java
+++ b/solr/core/src/test/org/apache/solr/search/function/SortByFunctionTest.java
@@ -22,7 +22,7 @@ import org.junit.BeforeClass;
/**
*
- *
+ * @see TestSortByMinMaxFunction
**/
public class SortByFunctionTest extends AbstractSolrTestCase {
@@ -129,11 +129,23 @@ public class SortByFunctionTest extends AbstractSolrTestCase {
"//result/doc[4]/int[@name='id'][.='1']"
);
}
+
+ /**
+ * The sort clauses to test in <code>testFieldSortSpecifiedAsFunction</code>.
+ *
+ * @see #testFieldSortSpecifiedAsFunction
+ */
+ protected String[] getFieldFunctionClausesToTest() {
+ return new String[] { "primary_tl1", "field(primary_tl1)" };
+ }
+
/**
* Sort by function normally compares the double value, but if a function is specified that identifies
* a single field, we should use the underlying field's SortField to save of a lot of type converstion
* (and RAM), and keep the sort precision as high as possible
+ *
+ * @see #getFieldFunctionClausesToTest
*/
public void testFieldSortSpecifiedAsFunction() throws Exception {
final long A = Long.MIN_VALUE;
@@ -170,8 +182,9 @@ public class SortByFunctionTest extends AbstractSolrTestCase {
assertU(commit());
// all of these sorts should result in the exact same order
- for (String primarySort : new String[] { "primary_tl1", "field(primary_tl1)",
- "field(multi_l_dv,max)", "field(multi_l_dv,min)" }) {
+ // min/max of a field is tested in TestSortByMinMaxFunction
+ for (String primarySort : getFieldFunctionClausesToTest()) {
+
assertQ(req("q", "*:*",
"sort", primarySort + " asc, secondary_tl1 asc")
, "//*[@numFound='9']"
diff --git a/solr/core/src/test/org/apache/solr/search/function/TestSortByMinMaxFunction.java b/solr/core/src/test/org/apache/solr/search/function/TestSortByMinMaxFunction.java
new file mode 100644
index 00000000000..ff780362eba
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/search/function/TestSortByMinMaxFunction.java
@@ -0,0 +1,38 @@
+package org.apache.solr.search.function;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.BeforeClass;
+
+
+
+/**
+ * Split out from SortByFunctionTest due to codec support limitations for SortedSetSelector
+ *
+ * @see SortByFunctionTest
+ **/
+@SuppressCodecs({"Memory", "SimpleText"}) // see TestSortedSetSelector
+public class TestSortByMinMaxFunction extends SortByFunctionTest {
+
+ @Override
+ public String[] getFieldFunctionClausesToTest() {
+ return new String[] { "primary_tl1", "field(primary_tl1)",
+ "field(multi_l_dv,max)", "field(multi_l_dv,min)" };
+ }
+}