jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch master updated: JMESPathExtractor Attribute Match No. Required
Date Sat, 24 Apr 2021 09:47:14 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new b5a3c91  JMESPathExtractor Attribute Match No. Required
b5a3c91 is described below

commit b5a3c9113e0ca084b749afdd55a526a285272ae7
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sat Apr 24 11:45:56 2021 +0200

    JMESPathExtractor Attribute Match No. Required
    
    Bugzilla Id: 65259
---
 .../jmeter/extractor/json/jmespath/JMESPathExtractor.java    |  7 ++++++-
 .../extractor/json/jmespath/TestJMESPathExtractor.java       | 12 ++++++++++++
 xdocs/changes.xml                                            |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java
b/src/components/src/main/java/org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java
index dc130c1..8e25c0f 100644
--- a/src/components/src/main/java/org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java
+++ b/src/components/src/main/java/org/apache/jmeter/extractor/json/jmespath/JMESPathExtractor.java
@@ -63,7 +63,12 @@ public class JMESPathExtractor extends AbstractScopedTestElement
         String jsonResponse = getData(vars, context);
         String refName = getRefName();
         String defaultValue = getDefaultValue();
-        int matchNumber = Integer.parseInt(getMatchNumber());
+        int matchNumber;
+        if (StringUtils.isBlank(getMatchNumber())) {
+            matchNumber = 0;
+        } else {
+            matchNumber = Integer.parseInt(getMatchNumber());
+        }
         final String jsonPathExpression = getJmesPathExpression().trim();
         clearOldRefVars(vars, refName);
         if (StringUtils.isEmpty(jsonResponse)) {
diff --git a/src/components/src/test/java/org/apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java
b/src/components/src/test/java/org/apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java
index 8465fe2..bc58d58 100644
--- a/src/components/src/test/java/org/apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java
+++ b/src/components/src/test/java/org/apache/jmeter/extractor/json/jmespath/TestJMESPathExtractor.java
@@ -58,6 +58,18 @@ public class TestJMESPathExtractor {
         return processor;
     }
 
+    public static class NonParemeterizedTests {
+        @Test
+        public void testNoMatchNumberSet() {
+            JMeterVariables vars = new JMeterVariables();
+            SampleResult sampleResult = new SampleResult();
+            JMESPathExtractor processor = setupProcessor(vars, sampleResult, "[1]", false,
"");
+            processor.setJmesPathExpression("[*]");
+            processor.process();
+            assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is("1"));
+        }
+    }
+
     @RunWith(Parameterized.class)
     public static class OneMatchOnAllExtractedValues {
 
diff --git a/xdocs/changes.xml b/xdocs/changes.xml
index 571b571..b294d31 100644
--- a/xdocs/changes.xml
+++ b/xdocs/changes.xml
@@ -160,6 +160,7 @@ Summary
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>
 <ul>
   <li><bug>65257</bug>JMESPathExtractor writes error log entries if JMESPath
filter returns empty result</li>
+  <li><bug>65259</bug>JMESPathExtractor Attribute <code>Match No.</code>
Required</li>
 </ul>
 
 <h3>Functions</h3>

Mime
View raw message