Author: pmouawad
Date: Mon Oct 29 09:23:45 2018
New Revision: 1845093

URL: http://svn.apache.org/viewvc?rev=1845093&view=rev
Log:
Bug 62860 - JSON Extractor : Avoid NPE and noisy error message "Error 
processing JSON content in" when variable is not found
Bugzilla Id: 62860

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java

Modified: 
jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java?rev=1845093&r1=1845092&r2=1845093&view=diff
==============================================================================
--- 
jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java 
(original)
+++ 
jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java 
Mon Oct 29 09:23:45 2018
@@ -111,6 +111,28 @@ public class TestJSONPostProcessor {
         assertThat(vars.get("varname_1"), 
CoreMatchers.is(CoreMatchers.nullValue()));
         assertThat(vars.get("varname_2"), 
CoreMatchers.is(CoreMatchers.nullValue()));
     }
+    
+    @Test
+    public void testCaseEmptyVarBug62860() {
+        JMeterContext context = JMeterContextService.getContext();
+        JSONPostProcessor processor = setupProcessor(context, "0", false);
+        JMeterVariables vars = new JMeterVariables();
+        processor.setDefaultValues("NONE");
+        processor.setJsonPathExpressions("$[*]");
+        processor.setRefNames("varname");
+        processor.setScopeVariable("contentvar");
+        context.setVariables(vars);
+        vars.remove("contentvar");
+        processor.process();
+        assertThat(vars.get("varname"), CoreMatchers.is("NONE"));
+        assertThat(vars.get("varname_matchNr"), 
CoreMatchers.is(CoreMatchers.nullValue()));
+        
+        vars.put("contentvar", "");
+        processor.process();
+        assertThat(vars.get("varname"), CoreMatchers.is("NONE"));
+        assertThat(vars.get("varname_matchNr"), 
CoreMatchers.is(CoreMatchers.nullValue()));
+
+    }
 
     @Test
     public void testPR235CaseMatchOneWithZero() {


Reply via email to