From 0752c07c1c65c8f1ce1c90e1c6f694e9a9509c64 Mon Sep 17 00:00:00 2001 From: Munendra S N Date: Wed, 10 Jul 2019 10:17:55 +0530 Subject: [PATCH] SOLR-11263: add test for payload func with undefined field Payload func with undefined used to throw NPE. In SOLR-11610, this was fixed to return proper error but there are no tests to verify changed the behavior. This add simple test to verify error code and error message --- .../org/apache/solr/search/function/TestFunctionQuery.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java index de10cee4828..499bb6eec2c 100644 --- a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java +++ b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java @@ -470,6 +470,10 @@ public class TestFunctionQuery extends SolrTestCaseJ4 { ); // this should pass assertQ(req("q", "*:*","defType","edismax", "boost","recip(1, 2, 3, 4)")); + + // for undefined field NPE shouldn't be thrown + assertQEx("Should Fail as the field is undefined", "undefined field a", + req("q", "*:*", "fl", "x:payload(a,b)"), SolrException.ErrorCode.BAD_REQUEST); } @Test