From 9fb103641dfe750d7940e7ea68110e1b807d69ff Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 27 Jun 2023 13:45:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DjsonPath=E6=96=AD=E8=A8=80=E7=B2=BE=E5=BA=A6?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1026684 --user=王孝刚 【接口测试】github #24735 1.20.23LTS JSONPath断言 正则比对3260.00 != 3260.0 导致之前写的正则比对报错 https://www.tapd.cn/55049933/s/1386814 --- .../org/apache/jmeter/assertions/JSONPathAssertion.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java b/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java index 6552c31acf..0f06d14ee4 100644 --- a/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java +++ b/framework/sdk-parent/jmeter/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java @@ -195,7 +195,7 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab List result = new ArrayList<>(); for (Object subj : value.toArray()) { - if (!StringUtils.equals(getOption(), "NOT_CONTAINS")) { + if (!StringUtils.equalsAnyIgnoreCase(getOption(), "NOT_CONTAINS","EQUALS")) { if (subj == null && this.isExpectNull() || isEquals(subj)) { return true; } @@ -203,7 +203,7 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab result.add(isEquals(subj)); } } - if (CollectionUtils.isNotEmpty(result) && StringUtils.equals(getOption(), "NOT_CONTAINS")) { + if (CollectionUtils.isNotEmpty(result) && StringUtils.equalsAnyIgnoreCase(getOption(), "NOT_CONTAINS", "EQUALS")) { if (result.stream().filter(item -> item == true).collect(Collectors.toList()).size() == result.size()) { return true; } else { @@ -281,8 +281,8 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab private static boolean valueEquals(String v1, String v2) { try { - Number number1 = NumberUtils.createNumber(v1); - Number number2 = NumberUtils.createNumber(v2); + Number number1 = NumberUtils.createBigDecimal(v1); + Number number2 = NumberUtils.createBigDecimal(v2); return number1.equals(number2); } catch (Exception e) { return StringUtils.equals(v1, v2);