Skip to content
Permalink
Browse files
Add a switch to decide which regex engine should be used
  • Loading branch information
FSchumacher committed Mar 5, 2022
1 parent a9f5127 commit 046ebacadbd7bc23273fc854661aa02628ad7381
Showing 1 changed file with 8 additions and 2 deletions.
@@ -51,6 +51,8 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
public static final String INVERT = "INVERT";
public static final String ISREGEX = "ISREGEX";

private boolean useJavaRegex = JMeterUtils.getPropDefault("jmeter.use_java_regex", false);

private static ThreadLocal<DecimalFormat> decimalFormatter =
ThreadLocal.withInitial(JSONPathAssertion::createDecimalFormat);

@@ -164,8 +166,12 @@ private boolean arrayMatched(JSONArray value) {
private boolean isEquals(Object subj) {
if (isUseRegex()) {
String str = objectToString(subj);
Pattern pattern = JMeterUtils.getPatternCache().getPattern(getExpectedValue());
return JMeterUtils.getMatcher().matches(str, pattern);
if (useJavaRegex) {
return java.util.regex.Pattern.matches(getExpectedValue(), str);
} else {
Pattern pattern = JMeterUtils.getPatternCache().getPattern(getExpectedValue());
return JMeterUtils.getMatcher().matches(str, pattern);
}
} else {
Object expected = JSONValue.parse(getExpectedValue());
return Objects.equals(expected, subj);

0 comments on commit 046ebac

Please sign in to comment.