Skip to content

Apache Lucene open-source search software

SOLR-2468: fix test added by SOLR-2335 that doesn't work on windows (double-quote in file name)

Chris M. Hostettera5d2b89dff1b
diff --git a/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java b/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
index fb154ccce7b..28f427f82d6 100755
--- a/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
+++ b/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
@@ -523,11 +523,12 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
* verify that both the field("...") value source parser as well as
* ExternalFileField work with esoteric field names
*/
- @Test @Ignore("fails on some platforms: see https://issues.apache.org/jira/browse/SOLR-2468")
+ @Test
public void testExternalFieldValueSourceParser() {
+ clearIndex();
- String field = "CoMpleX \" fieldName _extf";
- String fieldAsFunc = "field(\"CoMpleX \\\" fieldName _extf\")";
+ String field = "CoMpleX fieldName _extf";
+ String fieldAsFunc = "field(\"CoMpleX fieldName _extf\")";
float[] ids = {100,-4,0,10,25,5,77,23,55,-78,-45,-24,63,78,94,22,34,54321,261,-627};
@@ -544,7 +545,7 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
singleTest(fieldAsFunc, "sqrt(\0)");
assertTrue(orig == FileFloatSource.onlyForTesting);
- makeExternalFile(fieldAsFunc, "0=1","UTF-8");
+ makeExternalFile(field, "0=1","UTF-8");
assertU(adoc("id", "10000")); // will get same reader if no index change
assertU(commit());
singleTest(fieldAsFunc, "sqrt(\0)");
@@ -553,4 +554,31 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
purgeFieldCache(FieldCache.DEFAULT); // avoid FC insanity
}
+ /**
+ * some platforms don't allow quote characters in filenames, so
+ * in addition to testExternalFieldValueSourceParser above, test a field
+ * name with quotes in it that does NOT use ExternalFileField
+ * @see #testExternalFieldValueSourceParser
+ */
+ @Test
+ public void testFieldValueSourceParser() {
+ clearIndex();
+
+ String field = "CoMpleX \" fieldName _f";
+ String fieldAsFunc = "field(\"CoMpleX \\\" fieldName _f\")";
+
+ float[] ids = {100,-4,0,10,25,5,77,1};
+
+ createIndex(field, ids);
+
+ // test identity (straight field value)
+ singleTest(fieldAsFunc, "\0",
+ 100,100, -4,-4, 0,0, 10,10, 25,25, 5,5, 77,77, 1,1);
+ singleTest(fieldAsFunc, "sqrt(\0)",
+ 100,10, 25,5, 0,0, 1,1);
+ singleTest(fieldAsFunc, "log(\0)", 1,0);
+
+ purgeFieldCache(FieldCache.DEFAULT); // avoid FC insanity
+ }
+
}