You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2021/09/11 13:12:02 UTC
[jmeter] branch master updated: Convert test to jupiter (JUnit 5)
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 7174d53 Convert test to jupiter (JUnit 5)
7174d53 is described below
commit 7174d53e84eb2b75fca11e8d4ce77f51cde17d39
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sat Sep 11 13:31:41 2021 +0200
Convert test to jupiter (JUnit 5)
Try to get rid of all old junit 4 style tests by converting them.
---
.../assertions/jmespath/TestJMESPathAssertion.java | 280 +++++------
.../json/jmespath/TestJMESPathExtractor.java | 552 +++++++++------------
.../jmeter/visualizers/TestSampleCompareTo.java | 45 +-
.../samplers/TestDataStrippingSampleSender.java | 35 +-
.../jmeter/util/SecurityProviderLoaderTest.java | 22 +-
.../apache/jorphan/gui/MinMaxLongRendererTest.java | 41 +-
.../protocol/http/sampler/SamplingNamingTest.java | 30 +-
7 files changed, 432 insertions(+), 573 deletions(-)
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/jmespath/TestJMESPathAssertion.java b/src/components/src/test/java/org/apache/jmeter/assertions/jmespath/TestJMESPathAssertion.java
index 4f8ce72..3e9959d 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/jmespath/TestJMESPathAssertion.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/jmespath/TestJMESPathAssertion.java
@@ -20,18 +20,14 @@ package org.apache.jmeter.assertions.jmespath;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
import org.apache.jmeter.assertions.AssertionResult;
import org.apache.jmeter.samplers.SampleResult;
-import org.junit.Test;
-import org.junit.experimental.runners.Enclosed;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
-@RunWith(Enclosed.class)
public class TestJMESPathAssertion {
private enum InvertType {
USE_NO_INVERT, USE_INVERT
@@ -49,156 +45,128 @@ public class TestJMESPathAssertion {
SUCCESS, ERROR, FAILURE
}
- @RunWith(Parameterized.class)
- public static class TestAssertion {
- private static final String JSON_ARRAY =
- "{\"people\": [ {\"name\": \"b\", \"age\": 30},"
- + " {\"name\": \"a\", \"age\": 50},"
- + " {\"name\": \"c\", \"age\": 40}"
- + " ]"
- + "}";
+ private static final String JSON_ARRAY =
+ "{\"people\": [ {\"name\": \"b\", \"age\": 30},"
+ + " {\"name\": \"a\", \"age\": 50},"
+ + " {\"name\": \"c\", \"age\": 40}"
+ + " ]"
+ + "}";
- @Parameters(name = "index:{index} => data({1}, jmespath={2}, invert={0}, validation:{3}, regex:{4}, nullability:{5}, "
- + "expected value:{6}, expected result type:{7}, expected failure message:{8})")
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] {
- { InvertType.USE_INVERT, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "[6:6]", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "[]", ResultType.FAILURE,
- "Value expected not to be equal to []" },
- { InvertType.USE_NO_INVERT, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "[6:6]",
- ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
- "[]", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "[6:6]",
- ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
- "[1]", ResultType.FAILURE, "Value expected to be equal to [1]" },
- { InvertType.USE_NO_INVERT, "{\"one\": \"1\",\"two\": \"2\"}", "[one,two]",
- ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
- "[\"1\",\"2\"]", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "{\"a\": \"foo\", \"b\": \"bar\", \"c\": \"baz\"}", "a",
- ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
- "foo", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "{\"a\": \"123\"}", "a", ValidationType.USE_VALIDATION,
- ComparisonType.USE_REGEX, ResultNullity.EXPECT_NOT_NULL, "123|456", ResultType.SUCCESS,
- "" },
- { InvertType.USE_NO_INVERT, "{\"a\": \"123\"}", "a", ValidationType.USE_VALIDATION,
- ComparisonType.USE_REGEX, ResultNullity.EXPECT_NOT_NULL, "789|012", ResultType.FAILURE,
- "Value expected to match 789|012" },
- { InvertType.USE_INVERT, "{\"a\": \"123\"}", "a", ValidationType.USE_VALIDATION,
- ComparisonType.USE_REGEX, ResultNullity.EXPECT_NOT_NULL, "123|012", ResultType.FAILURE,
- "Value expected not to match 123|012" },
- { InvertType.USE_NO_INVERT, JSON_ARRAY, "max_by(people, &age).name", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "a", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "two", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, null, ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, "1", ResultType.FAILURE,
- "Value expected to be null" },
- { InvertType.USE_INVERT, "{\"one\": \"1\"}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "2", ResultType.SUCCESS, "" },
- { InvertType.USE_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, "", ResultType.SUCCESS, "" },
- { InvertType.USE_INVERT, "{\"one\": \"\"}", "two", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, "", ResultType.FAILURE,
- "Value expected not to be null" },
-
- { InvertType.USE_NO_INVERT, "{\"one\": \"1\"}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "2", ResultType.FAILURE,
- "Value expected to be equal to 2" },
-
- { InvertType.USE_INVERT, "{\"one\": \"1\"}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "1", ResultType.FAILURE,
- "Value expected not to be equal to 1" },
- { InvertType.USE_INVERT, "{'one': '1'}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "2", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "{'one': '1'}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "2", ResultType.ERROR,
- "Unexpected character (''' (code 39)): was expecting double-quote to start field name\n at"
- + " [Source: (String)\"{'one': '1'}\"; line: 1, column: 3]" },
- { InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "1", ResultType.FAILURE,
- "Value expected to be equal to 1" },
- { InvertType.USE_NO_INVERT, "{\"\":\"\"}", "foo", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, null, ResultType.SUCCESS, "" },
-
- { InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_NO_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "two", ValidationType.USE_NO_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.FAILURE,
- "JMESPATH two expected to exist" },
- { InvertType.USE_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_NO_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.FAILURE,
- "JMESPATH one expected not to exist" },
- { InvertType.USE_INVERT, "{\"one\": \"\"}", "two", ValidationType.USE_NO_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "", "two", ValidationType.USE_NO_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.FAILURE,
- AssertionResult.RESPONSE_WAS_NULL },
- { InvertType.USE_NO_INVERT,
- "{\n" + " \"reservations\": [\n" + " {\n" + " \"instances\": [\n"
- + " {\"state\": \"running\"},\n" + " {\"state\": \"stopped\"}\n"
- + " ]\n" + " },\n" + " {\n" + " \"instances\": [\n"
- + " {\"state\": \"terminated\"},\n" + " {\"state\": \"running\"}\n"
- + " ]\n" + " }\n" + " ]\n" + "}",
- "reservations[*].instances[*].state", ValidationType.USE_VALIDATION,
- ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
- "[[\"running\",\"stopped\"],[\"terminated\",\"running\"]]", ResultType.SUCCESS, "" },
- { InvertType.USE_NO_INVERT, "{\"x\": {\"a\": 23, \"b\": 42, \"c\": \"something\"}}", "x",
- ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
- "{\n\t\"a\": 23,\n\t\"b\": 42,\n\t\"c\": \"something\"\n}", ResultType.SUCCESS,
- "" } });
- }
-
-
- private InvertType isInverted;
- private String responseData;
- private String jmesPath;
- private ValidationType isValidation;
- private ComparisonType isRegex;
- private ResultNullity isExpectedNull;
- private String expectedValue;
- private ResultType resultType;
- private String failureMessage;
-
- public TestAssertion(InvertType isInverted, String responseData, String jmesPath, ValidationType isValidation, ComparisonType isRegex,
- ResultNullity isExpectedNull, String expectedValue, ResultType resultType, String failureMessage) {
- super();
- this.isInverted = isInverted;
- this.responseData = responseData;
- this.jmesPath = jmesPath;
- this.isValidation = isValidation;
- this.isRegex = isRegex;
- this.isExpectedNull = isExpectedNull;
- this.expectedValue = expectedValue;
- this.resultType = resultType;
- this.failureMessage = failureMessage;
- }
+ private static Stream<Arguments> data() {
+ return Stream.of(
+ Arguments.of(InvertType.USE_INVERT, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "[6:6]", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "[]", ResultType.FAILURE,
+ "Value expected not to be equal to []"),
+ Arguments.of(InvertType.USE_NO_INVERT, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "[6:6]",
+ ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
+ "[]", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "[6:6]",
+ ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
+ "[1]", ResultType.FAILURE, "Value expected to be equal to [1]"),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"one\": \"1\",\"two\": \"2\"}", "[one,two]",
+ ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
+ "[\"1\",\"2\"]", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"a\": \"foo\", \"b\": \"bar\", \"c\": \"baz\"}", "a",
+ ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
+ "foo", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"a\": \"123\"}", "a", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_REGEX, ResultNullity.EXPECT_NOT_NULL, "123|456", ResultType.SUCCESS,
+ ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"a\": \"123\"}", "a", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_REGEX, ResultNullity.EXPECT_NOT_NULL, "789|012", ResultType.FAILURE,
+ "Value expected to match 789|012"),
+ Arguments.of(InvertType.USE_INVERT, "{\"a\": \"123\"}", "a", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_REGEX, ResultNullity.EXPECT_NOT_NULL, "123|012", ResultType.FAILURE,
+ "Value expected not to match 123|012"),
+ Arguments.of(InvertType.USE_NO_INVERT, JSON_ARRAY, "max_by(people, &age).name", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "a", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "two", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, null, ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, "1", ResultType.FAILURE,
+ "Value expected to be null"),
+ Arguments.of(InvertType.USE_INVERT, "{\"one\": \"1\"}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "2", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, "", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_INVERT, "{\"one\": \"\"}", "two", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, "", ResultType.FAILURE,
+ "Value expected not to be null"),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"one\": \"1\"}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "2", ResultType.FAILURE,
+ "Value expected to be equal to 2" ),
+ Arguments.of(InvertType.USE_INVERT, "{\"one\": \"1\"}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "1", ResultType.FAILURE,
+ "Value expected not to be equal to 1"),
+ Arguments.of(InvertType.USE_INVERT, "{'one': '1'}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "2", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{'one': '1'}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "2", ResultType.ERROR,
+ "Unexpected character (''' (code 39)): was expecting double-quote to start field name\n at"
+ + " [Source: (String)\"{'one': '1'}\"; line: 1, column: 3]"),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "1", ResultType.FAILURE,
+ "Value expected to be equal to 1"),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"\":\"\"}", "foo", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NULL, null, ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_NO_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"one\": \"\"}", "two", ValidationType.USE_NO_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.FAILURE,
+ "JMESPATH two expected to exist"),
+ Arguments.of(InvertType.USE_INVERT, "{\"one\": \"\"}", "one", ValidationType.USE_NO_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.FAILURE,
+ "JMESPATH one expected not to exist"),
+ Arguments.of(InvertType.USE_INVERT, "{\"one\": \"\"}", "two", ValidationType.USE_NO_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "", "two", ValidationType.USE_NO_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL, "", ResultType.FAILURE,
+ AssertionResult.RESPONSE_WAS_NULL),
+ Arguments.of(InvertType.USE_NO_INVERT,
+ "{\n" + " \"reservations\": [\n" + " {\n" + " \"instances\": [\n"
+ + " {\"state\": \"running\"},\n" + " {\"state\": \"stopped\"}\n"
+ + " ]\n" + " },\n" + " {\n" + " \"instances\": [\n"
+ + " {\"state\": \"terminated\"},\n" + " {\"state\": \"running\"}\n"
+ + " ]\n" + " }\n" + " ]\n" + "}",
+ "reservations[*].instances[*].state", ValidationType.USE_VALIDATION,
+ ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
+ "[[\"running\",\"stopped\"],[\"terminated\",\"running\"]]", ResultType.SUCCESS, ""),
+ Arguments.of(InvertType.USE_NO_INVERT, "{\"x\": {\"a\": 23, \"b\": 42, \"c\": \"something\"}}", "x",
+ ValidationType.USE_VALIDATION, ComparisonType.USE_NO_REXEG, ResultNullity.EXPECT_NOT_NULL,
+ "{\n\t\"a\": 23,\n\t\"b\": 42,\n\t\"c\": \"something\"\n}", ResultType.SUCCESS,
+ "" ));
+ }
- @Test
- public void test() {
- SampleResult samplerResult = new SampleResult();
- samplerResult.setResponseData(responseData, null);
- JMESPathAssertion instance = new JMESPathAssertion();
- instance.setJmesPath(jmesPath);
- instance.setJsonValidationBool(isValidation == ValidationType.USE_VALIDATION);
- instance.setInvert(isInverted == InvertType.USE_INVERT);
- instance.setIsRegex(isRegex == ComparisonType.USE_REGEX);
- instance.setExpectNull(isExpectedNull == ResultNullity.EXPECT_NULL);
- instance.setExpectedValue(expectedValue);
- AssertionResult expResult = new AssertionResult("");
- AssertionResult result = instance.getResult(samplerResult);
- assertEquals(expResult.getName(), result.getName());
- if (result.isError() && !result.isFailure()) {
- assertEquals(ResultType.ERROR, resultType);
- } else if (result.isFailure() && !result.isError()) {
- assertEquals(ResultType.FAILURE, resultType);
- } else if (!result.isError() && !result.isFailure()){
- assertEquals(ResultType.SUCCESS, resultType);
- } else {
- fail("Got unexpected state where AssertionResult is in error and in failure");
- }
- assertEquals(failureMessage, result.getFailureMessage());
+ @ParameterizedTest(
+ name = "index:{index} => data({1}, jmespath={2}, invert={0}, validation:{3}, regex:{4}, nullability:{5}, "
+ + "expected value:{6}, expected result type:{7}, expected failure message:{8})")
+ @MethodSource("data")
+ void test(InvertType isInverted, String responseData, String jmesPath, ValidationType isValidation,
+ ComparisonType isRegex, ResultNullity isExpectedNull, String expectedValue, ResultType resultType,
+ String failureMessage) {
+ SampleResult samplerResult = new SampleResult();
+ samplerResult.setResponseData(responseData, null);
+ JMESPathAssertion instance = new JMESPathAssertion();
+ instance.setJmesPath(jmesPath);
+ instance.setJsonValidationBool(isValidation == ValidationType.USE_VALIDATION);
+ instance.setInvert(isInverted == InvertType.USE_INVERT);
+ instance.setIsRegex(isRegex == ComparisonType.USE_REGEX);
+ instance.setExpectNull(isExpectedNull == ResultNullity.EXPECT_NULL);
+ instance.setExpectedValue(expectedValue);
+ AssertionResult expResult = new AssertionResult("");
+ AssertionResult result = instance.getResult(samplerResult);
+ assertEquals(expResult.getName(), result.getName());
+ if (result.isError() && !result.isFailure()) {
+ assertEquals(ResultType.ERROR, resultType);
+ } else if (result.isFailure() && !result.isError()) {
+ assertEquals(ResultType.FAILURE, resultType);
+ } else if (!result.isError() && !result.isFailure()) {
+ assertEquals(ResultType.SUCCESS, resultType);
+ } else {
+ fail("Got unexpected state where AssertionResult is in error and in failure");
}
+ assertEquals(failureMessage, result.getFailureMessage());
}
}
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 479e968..5008462 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
@@ -19,9 +19,8 @@ package org.apache.jmeter.extractor.json.jmespath;
import static org.hamcrest.MatcherAssert.assertThat;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.function.Consumer;
+import java.util.stream.Stream;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.testelement.AbstractScopedTestElement;
@@ -29,13 +28,12 @@ import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-import org.junit.experimental.runners.Enclosed;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runners.Parameterized.Parameters;
-@RunWith(Enclosed.class)
public class TestJMESPathExtractor {
private static final String DEFAULT_VALUE = "NONE"; // $NON-NLS-1$
private static final String REFERENCE_NAME = "varname"; // $NON-NLS-1$
@@ -60,344 +58,272 @@ 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"));
- }
+ @Test
+ 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 {
-
- @Parameters(name = "Extract from {0} with path {1} should result in {2} for match {3}")
- public static Collection<String[]> data() {
- return Arrays.asList(new String[][] {
- {"[\"one\"]", "[*]", "one", "1"},
- {"{\"a\": {\"b\": {\"c\": {\"d\": \"value\"}}}}", "a.b.c.d", "value", "1"},
- {"{\r\n" + " \"people\": [\r\n" + " {\"first\": \"James\", \"last\": \"d\"},\r\n"
- + " {\"first\": \"Jacob\", \"last\": \"e\"},\r\n"
- + " {\"first\": \"Jayden\", \"last\": \"f\"},\r\n" + " {\"missing\": \"different\"}\r\n"
- + " ],\r\n" + " \"foo\": {\"bar\": \"baz\"}\r\n" + "}", "people[2]",
- "{\"first\":\"Jayden\",\"last\":\"f\"}",
- "1"}
- });
- }
-
- private String data;
- private String jmesPath;
- private String expectedResult;
- private String expectedMatchNumber;
-
- public OneMatchOnAllExtractedValues(String data, String jmesPath, String expectedResult, String expectedMatchNumber) {
- this.data = data;
- this.jmesPath = jmesPath;
- this.expectedResult = expectedResult;
- this.expectedMatchNumber = expectedMatchNumber;
- }
-
- @Test
- public void testFromVars() {
- test(true);
- }
-
- @Test
- public void testFromSampleResult() {
- test(false);
- }
-
- public void test(boolean fromVars) {
- JMeterVariables vars = new JMeterVariables();
- SampleResult sampleResult = new SampleResult();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, data, fromVars, "-1");
- processor.setJmesPathExpression(jmesPath);
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(CoreMatchers.nullValue()));
- assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(expectedResult));
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(expectedMatchNumber));
-
- processor.clearOldRefVars(vars, REFERENCE_NAME);
- assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(CoreMatchers.nullValue()));
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(CoreMatchers.nullValue()));
- }
+ private static Stream<Arguments> dataOneMatch() {
+ return Stream.of(
+ Arguments.of("[\"one\"]", "[*]", "one", "1"),
+ Arguments.of("{\"a\": {\"b\": {\"c\": {\"d\": \"value\"}}}}", "a.b.c.d", "value", "1"),
+ Arguments.of("{\r\n" + " \"people\": [\r\n" + " {\"first\": \"James\", \"last\": \"d\"},\r\n"
+ + " {\"first\": \"Jacob\", \"last\": \"e\"},\r\n"
+ + " {\"first\": \"Jayden\", \"last\": \"f\"},\r\n" + " {\"missing\": \"different\"}\r\n"
+ + " ],\r\n" + " \"foo\": {\"bar\": \"baz\"}\r\n" + "}", "people[2]",
+ "{\"first\":\"Jayden\",\"last\":\"f\"}",
+ "1")
+ );
}
- @RunWith(Parameterized.class)
- public static class MultipleMatchesOnAllExtractedValues {
-
- @Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] {
- {"[\"one\", \"two\"]", "[*]", new String[] {"one", "two"}, "2"},
- {"[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]", "[0:3]", new String[] {"a", "b","c"}, "3"},
- {"{\r\n" + " \"people\": [\r\n" + " {\"first\": \"James\", \"last\": \"d\"},\r\n"
- + " {\"first\": \"Jacob\", \"last\": \"e\"},\r\n"
- + " {\"first\": \"Jayden\", \"last\": \"f\"},\r\n" + " {\"missing\": \"different\"}\r\n"
- + " ],\r\n" + " \"foo\": {\"bar\": \"baz\"}\r\n" + "}", "people[:2].first", new String[] {"James", "Jacob"}, "2" },
- });
- }
-
- private String data;
- private String jmesPath;
- private String[] expectedResults;
- private String expectedMatchNumber;
-
- public MultipleMatchesOnAllExtractedValues(String data, String jmesPath, String[] expectedResults, String expectedMatchNumber) {
- this.data = data;
- this.jmesPath = jmesPath;
- this.expectedResults = expectedResults;
- this.expectedMatchNumber = expectedMatchNumber;
- }
-
- @Test
- public void testFromVars() {
- test(true);
- }
-
- @Test
- public void testFromSampleResult() {
- test(false);
- }
+ @ParameterizedTest(name = "TestFromVars: {index} Extract from {0} with path {1} should result in {2} for match {3}")
+ @MethodSource("dataOneMatch")
+ void testOneMatchFromVars(String data, String jmesPath, String expectedResult, String expectedMatchNumber) {
+ testOneMatchOnAllExtractedValues(true, data, jmesPath, expectedResult, expectedMatchNumber);
+ }
- public void test(boolean fromVars) {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, data, fromVars, "-1");
- // test1
- processor.setJmesPathExpression(jmesPath);
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(CoreMatchers.nullValue()));
- for (int i = 0; i < expectedResults.length; i++) {
- assertThat(vars.get(REFERENCE_NAME + "_"+(i+1)), CoreMatchers.is(expectedResults[i]));
- }
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(expectedMatchNumber));
- }
+ @ParameterizedTest(name = "TestFromSampleResult: {index} Extract from {0} with path {1} should result in {2} for match {3}")
+ @MethodSource("dataOneMatch")
+ void testOneFromSampleResult(String data, String jmesPath, String expectedResult, String expectedMatchNumber) {
+ testOneMatchOnAllExtractedValues(false, data, jmesPath, expectedResult, expectedMatchNumber);
}
- @RunWith(Parameterized.class)
- public static class MatchNumberMoreThanZeroOn1ExtractedValue {
-
- private static final String TEST_DATA = "{\r\n" + " \"people\": [\r\n" + " {\"first\": \"James\", \"last\": \"d\", \"age\":10},\r\n"
- + " {\"first\": \"Jacob\", \"last\": \"e\", \"age\":20},\r\n"
- + " {\"first\": \"Jayden\", \"last\": \"f\", \"age\":30},\r\n"
- + " {\"missing\": \"different\"}\r\n" + " ],\r\n" + " \"foo\": {\"bar\": \"baz\"}\r\n"
- + "}";
-
- @Parameters
- public static Collection<String[]> data() {
- return Arrays.asList(new String[][] {
- {TEST_DATA, "people[:3].first", "1", "James", "3"},
- {TEST_DATA, "people[:3].first", "2", "Jacob", "3"},
- {TEST_DATA, "people[:3].first", "3", "Jayden", "3"},
- {TEST_DATA, "people[:3].age", "3", "30", "3"},
- {TEST_DATA, "people[:3].first", "4", DEFAULT_VALUE, "3"}
- });
- }
+ private void testOneMatchOnAllExtractedValues(boolean fromVars, String data, String jmesPath, String expectedResult, String expectedMatchNumber) {
+ JMeterVariables vars = new JMeterVariables();
+ SampleResult sampleResult = new SampleResult();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, data, fromVars, "-1");
+ processor.setJmesPathExpression(jmesPath);
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(CoreMatchers.nullValue()));
+ assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(expectedResult));
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(expectedMatchNumber));
+
+ processor.clearOldRefVars(vars, REFERENCE_NAME);
+ assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(CoreMatchers.nullValue()));
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(CoreMatchers.nullValue()));
+ }
- private String data;
- private String jmesPath;
- private String expectedResult;
- private String expectedMatchNumber;
- private String matchNumber;
-
- public MatchNumberMoreThanZeroOn1ExtractedValue(String data, String jmesPath,
- String matchNumber, String expectedResult, String expectedMatchNumber) {
- this.data = data;
- this.jmesPath = jmesPath;
- this.expectedResult = expectedResult;
- this.matchNumber = matchNumber;
- this.expectedMatchNumber = expectedMatchNumber;
- }
+ private static Stream<Arguments> dataMultipleMatches() {
+ return Stream.of(
+ Arguments.of("[\"one\", \"two\"]", "[*]", new String[] {"one", "two"}, "2"),
+ Arguments.of("[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"]", "[0:3]", new String[] {"a", "b","c"}, "3"),
+ Arguments.of("{\r\n" + " \"people\": [\r\n" + " {\"first\": \"James\", \"last\": \"d\"},\r\n"
+ + " {\"first\": \"Jacob\", \"last\": \"e\"},\r\n"
+ + " {\"first\": \"Jayden\", \"last\": \"f\"},\r\n" + " {\"missing\": \"different\"}\r\n"
+ + " ],\r\n" + " \"foo\": {\"bar\": \"baz\"}\r\n" + "}", "people[:2].first", new String[] {"James", "Jacob"}, "2")
+ );
+ }
- @Test
- public void testFromVars() {
- test(true);
- }
+ @ParameterizedTest
+ @MethodSource("dataMultipleMatches")
+ void testMultipleMatchesOnAllExtractedValuesFromVars(String data, String jmesPath, String[] expectedResults, String expectedMatchNumber) {
+ testMultipleMatchesOnAllExtractedValues(true, data, jmesPath, expectedResults, expectedMatchNumber);
+ }
- @Test
- public void testFromSampleResult() {
- test(false);
- }
+ @ParameterizedTest
+ @MethodSource("dataMultipleMatches")
+ void testMultipleMatchesOnAllExtractedValuesFromSampleResult(String data, String jmesPath, String[] expectedResults, String expectedMatchNumber) {
+ testMultipleMatchesOnAllExtractedValues(false, data, jmesPath, expectedResults, expectedMatchNumber);
+ }
- public void test(boolean fromVars) {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, data, fromVars, "1");
- processor.setMatchNumber(matchNumber);
- processor.setJmesPathExpression(jmesPath);
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(expectedResult));
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(expectedMatchNumber));
+ private void testMultipleMatchesOnAllExtractedValues(boolean fromVars, String data, String jmesPath, String[] expectedResults, String expectedMatchNumber) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, data, fromVars, "-1");
+ // test1
+ processor.setJmesPathExpression(jmesPath);
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(CoreMatchers.nullValue()));
+ for (int i = 0; i < expectedResults.length; i++) {
+ assertThat(vars.get(REFERENCE_NAME + "_"+(i+1)), CoreMatchers.is(expectedResults[i]));
}
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(expectedMatchNumber));
}
- @RunWith(Parameterized.class)
- public static class ScopedSamples {
+ private static final String TEST_DATA = "{\r\n" + " \"people\": [\r\n" + " {\"first\": \"James\", \"last\": \"d\", \"age\":10},\r\n"
+ + " {\"first\": \"Jacob\", \"last\": \"e\", \"age\":20},\r\n"
+ + " {\"first\": \"Jayden\", \"last\": \"f\", \"age\":30},\r\n"
+ + " {\"missing\": \"different\"}\r\n" + " ],\r\n" + " \"foo\": {\"bar\": \"baz\"}\r\n"
+ + "}";
+
+ @Parameters
+ private static Stream<Arguments> dataMatchNumberMoreThanZero() {
+ return Stream.of(
+ Arguments.of(TEST_DATA, "people[:3].first", "1", "James", "3"),
+ Arguments.of(TEST_DATA, "people[:3].first", "2", "Jacob", "3"),
+ Arguments.of(TEST_DATA, "people[:3].first", "3", "Jayden", "3"),
+ Arguments.of(TEST_DATA, "people[:3].age", "3", "30", "3"),
+ Arguments.of(TEST_DATA, "people[:3].first", "4", DEFAULT_VALUE, "3")
+ );
+ }
- enum AccessMode {
- ALL(AbstractScopedTestElement::setScopeAll),
- PARENT(AbstractScopedTestElement::setScopeParent),
- CHILDREN(AbstractScopedTestElement::setScopeChildren);
+ @ParameterizedTest
+ @MethodSource("dataMatchNumberMoreThanZero")
+ void testFromVars(String data, String jmesPath,
+ String matchNumber, String expectedResult, String expectedMatchNumber) {
+ testMatchNumberMoreThanZeroOn1ExtractedValue(true, data, jmesPath, matchNumber, expectedResult, expectedMatchNumber);
+ }
- private Consumer<AbstractScopedTestElement> applier;
+ @ParameterizedTest
+ @MethodSource("dataMatchNumberMoreThanZero")
+ void testFromSampleResult(String data, String jmesPath,
+ String matchNumber, String expectedResult, String expectedMatchNumber) {
+ testMatchNumberMoreThanZeroOn1ExtractedValue(false, data, jmesPath, matchNumber, expectedResult, expectedMatchNumber);
+ }
- AccessMode(Consumer<AbstractScopedTestElement> applier) {
- this.applier = applier;
- }
+ private void testMatchNumberMoreThanZeroOn1ExtractedValue(boolean fromVars, String data, String jmesPath,
+ String matchNumber, String expectedResult, String expectedMatchNumber) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, data, fromVars, "1");
+ processor.setMatchNumber(matchNumber);
+ processor.setJmesPathExpression(jmesPath);
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(expectedResult));
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(expectedMatchNumber));
+ }
- void configure(AbstractScopedTestElement element) {
- applier.accept(element);
- }
- }
+ enum AccessMode {
+ ALL(AbstractScopedTestElement::setScopeAll),
+ PARENT(AbstractScopedTestElement::setScopeParent),
+ CHILDREN(AbstractScopedTestElement::setScopeChildren);
- private AccessMode accessMode;
- private String resultObject;
- private String resultCount;
- private String matchNumber;
- private String path;
-
- public ScopedSamples(AccessMode accessMode, String path, String matchNumber, String result, String resultCount) {
- this.accessMode = accessMode;
- this.path = path;
- this.matchNumber = matchNumber;
- this.resultObject = result;
- this.resultCount = resultCount;
- }
+ private Consumer<AbstractScopedTestElement> applier;
- @Parameters(name = "{index}: Mode: {0} Path: {1} MatchNr: {2} Result: {3} Count: {4}")
- public static Collection<Object[]> data() {
- return Arrays.asList(
- new Object[][] {
- { AccessMode.ALL, "a", "1", "23", "2" },
- { AccessMode.ALL, "a", "2", "42", "2" },
- { AccessMode.ALL, "b", "0", "parent_only", "1" },
- { AccessMode.ALL, "c", "0", "child_only", "1" },
- { AccessMode.PARENT, "a", "1", "23", "1" },
- { AccessMode.PARENT, "b", "0", "parent_only", "1" },
- { AccessMode.PARENT, "c", "0", "NONE", "0" },
- { AccessMode.CHILDREN, "a", "1", "42", "1" },
- { AccessMode.CHILDREN, "b", "0", "NONE", "0" },
- { AccessMode.CHILDREN, "c", "0", "child_only", "1" },
- }
- );
+ AccessMode(Consumer<AbstractScopedTestElement> applier) {
+ this.applier = applier;
}
- @Test
- public void testRandomElementAllMatches() {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, "{\"a\": 23, \"b\": \"parent_only\"}", false, matchNumber);
- SampleResult subSample = new SampleResult();
- subSample.setResponseData("{\"a\": 42, \"c\": \"child_only\"}", null);
- sampleResult.addSubResult(subSample);
-
- processor.setJmesPathExpression(path);
- accessMode.configure(processor);
-
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(resultObject));
- assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(CoreMatchers.nullValue()));
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(resultCount));
+ void configure(AbstractScopedTestElement element) {
+ applier.accept(element);
}
-
}
- @RunWith(Parameterized.class)
- public static class SourceVarOrResponse {
- private boolean fromVariables;
-
- @Parameters
- public static Collection<Boolean> data() {
- return Arrays.asList(new Boolean[] {Boolean.TRUE, Boolean.FALSE} );
- }
-
- public SourceVarOrResponse(boolean fromVariables) {
- this.fromVariables = fromVariables;
- }
+ private static Stream<Arguments> dataScopedSamples() {
+ return Stream.of(
+ Arguments.of(AccessMode.ALL, "a", "1", "23", "2"),
+ Arguments.of(AccessMode.ALL, "a", "2", "42", "2"),
+ Arguments.of(AccessMode.ALL, "b", "0", "parent_only", "1"),
+ Arguments.of(AccessMode.ALL, "c", "0", "child_only", "1"),
+ Arguments.of(AccessMode.PARENT, "a", "1", "23", "1"),
+ Arguments.of(AccessMode.PARENT, "b", "0", "parent_only", "1"),
+ Arguments.of(AccessMode.PARENT, "c", "0", "NONE", "0"),
+ Arguments.of(AccessMode.CHILDREN, "a", "1", "42", "1"),
+ Arguments.of(AccessMode.CHILDREN, "b", "0", "NONE", "0"),
+ Arguments.of(AccessMode.CHILDREN, "c", "0", "child_only", "1")
+ );
+ }
- @Test
- public void testRandomElementOneMatch() {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, "{\"a\": {\"b\": {\"c\": {\"d\": \"value\"}}}}", fromVariables, "0");
-
- processor.setJmesPathExpression("a.b.c.d");
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is("value"));
- assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(CoreMatchers.nullValue()));
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is("1"));
- }
+ @ParameterizedTest(name = "{index}: Mode: {0} Path: {1} MatchNr: {2} Result: {3} Count: {4}")
+ @MethodSource("dataScopedSamples")
+ void testRandomElementAllMatches(AccessMode accessMode, String path, String matchNumber, String resultObject, String resultCount) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, "{\"a\": 23, \"b\": \"parent_only\"}", false, matchNumber);
+ SampleResult subSample = new SampleResult();
+ subSample.setResponseData("{\"a\": 42, \"c\": \"child_only\"}", null);
+ sampleResult.addSubResult(subSample);
+
+ processor.setJmesPathExpression(path);
+ accessMode.configure(processor);
+
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(resultObject));
+ assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(CoreMatchers.nullValue()));
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(resultCount));
+ }
- @Test
- public void testRandomElementMultipleMatches() {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, "[\"one\", \"two\"]", fromVariables, "0");
-
- processor.setJmesPathExpression("[*]");
- processor.process();
- assertThat(vars.get(REFERENCE_NAME),
- CoreMatchers.is(CoreMatchers.anyOf(CoreMatchers.is("one"), CoreMatchers.is("two"))));
- assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(CoreMatchers.nullValue()));
- assertThat(vars.get(REFERENCE_NAME + "_2"), CoreMatchers.is(CoreMatchers.nullValue()));
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is("2"));
- }
+ private static Stream<Arguments> dataSourceVarOrResponse() {
+ return Stream.of(Arguments.of(Boolean.TRUE), Arguments.of(Boolean.FALSE));
+ }
- @Test
- public void testEmptySourceData() {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, "", fromVariables, "-1");
+ @ParameterizedTest
+ @MethodSource("dataSourceVarOrResponse")
+ void testRandomElementOneMatch(boolean fromVariables) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, "{\"a\": {\"b\": {\"c\": {\"d\": \"value\"}}}}", fromVariables, "0");
+
+ processor.setJmesPathExpression("a.b.c.d");
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is("value"));
+ assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(CoreMatchers.nullValue()));
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is("1"));
+ }
- processor.setJmesPathExpression("[*]");
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(DEFAULT_VALUE));
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(CoreMatchers.nullValue()));
- }
+ @ParameterizedTest
+ @MethodSource("dataSourceVarOrResponse")
+ void testRandomElementMultipleMatches(boolean fromVariables) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, "[\"one\", \"two\"]", fromVariables, "0");
+
+ processor.setJmesPathExpression("[*]");
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME),
+ CoreMatchers.is(CoreMatchers.anyOf(CoreMatchers.is("one"), CoreMatchers.is("two"))));
+ assertThat(vars.get(REFERENCE_NAME + "_1"), CoreMatchers.is(CoreMatchers.nullValue()));
+ assertThat(vars.get(REFERENCE_NAME + "_2"), CoreMatchers.is(CoreMatchers.nullValue()));
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is("2"));
+ }
- @Test
- public void testErrorInJMESPath() {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, "{\"a\": {\"b\": {\"c\": {\"d\": \"value\"}}}}", fromVariables, "-1");
-
- processor.setJmesPathExpression("$.k");
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(DEFAULT_VALUE));
- assertThat(vars.get(REFERENCE_NAME+ "_1"), CoreMatchers.nullValue());
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.nullValue());
- }
+ @ParameterizedTest
+ @MethodSource("dataSourceVarOrResponse")
+ void testEmptySourceData(boolean fromVariables) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, "", fromVariables, "-1");
+
+ processor.setJmesPathExpression("[*]");
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(DEFAULT_VALUE));
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is(CoreMatchers.nullValue()));
+ }
- @Test
- public void testNoMatch() {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, "{\"a\": {\"b\": {\"c\": {\"d\": \"value\"}}}}", fromVariables, "-1");
-
- processor.setJmesPathExpression("a.b.c.f");
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(DEFAULT_VALUE));
- assertThat(vars.get(REFERENCE_NAME+ "_1"), CoreMatchers.nullValue());
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is("0"));
- }
+ @ParameterizedTest
+ @MethodSource("dataSourceVarOrResponse")
+ void testErrorInJMESPath(boolean fromVariables) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, "{\"a\": {\"b\": {\"c\": {\"d\": \"value\"}}}}", fromVariables, "-1");
+
+ processor.setJmesPathExpression("$.k");
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(DEFAULT_VALUE));
+ assertThat(vars.get(REFERENCE_NAME+ "_1"), CoreMatchers.nullValue());
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.nullValue());
+ }
- @Test
- public void testNoInput() {
- SampleResult sampleResult = new SampleResult();
- JMeterVariables vars = new JMeterVariables();
- JMESPathExtractor processor = setupProcessor(vars, sampleResult, "", fromVariables, "0");
-
- processor.setJmesPathExpression("a.b");
- processor.process();
- assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(DEFAULT_VALUE));
- assertThat(vars.get(REFERENCE_NAME+ "_1"), CoreMatchers.nullValue());
- assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.nullValue());
- }
+ @ParameterizedTest
+ @MethodSource("dataSourceVarOrResponse")
+ void testNoMatch(boolean fromVariables) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, "{\"a\": {\"b\": {\"c\": {\"d\": \"value\"}}}}", fromVariables, "-1");
+
+ processor.setJmesPathExpression("a.b.c.f");
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(DEFAULT_VALUE));
+ assertThat(vars.get(REFERENCE_NAME+ "_1"), CoreMatchers.nullValue());
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.is("0"));
+ }
+ @ParameterizedTest
+ @MethodSource("dataSourceVarOrResponse")
+ void testNoInput(boolean fromVariables) {
+ SampleResult sampleResult = new SampleResult();
+ JMeterVariables vars = new JMeterVariables();
+ JMESPathExtractor processor = setupProcessor(vars, sampleResult, "", fromVariables, "0");
+
+ processor.setJmesPathExpression("a.b");
+ processor.process();
+ assertThat(vars.get(REFERENCE_NAME), CoreMatchers.is(DEFAULT_VALUE));
+ assertThat(vars.get(REFERENCE_NAME+ "_1"), CoreMatchers.nullValue());
+ assertThat(vars.get(REFERENCE_NAME_MATCH_NUMBER), CoreMatchers.nullValue());
}
}
diff --git a/src/components/src/test/java/org/apache/jmeter/visualizers/TestSampleCompareTo.java b/src/components/src/test/java/org/apache/jmeter/visualizers/TestSampleCompareTo.java
index 3fa6080..38ea2aa 100644
--- a/src/components/src/test/java/org/apache/jmeter/visualizers/TestSampleCompareTo.java
+++ b/src/components/src/test/java/org/apache/jmeter/visualizers/TestSampleCompareTo.java
@@ -19,40 +19,31 @@ package org.apache.jmeter.visualizers;
import static org.hamcrest.MatcherAssert.assertThat;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
-@RunWith(Parameterized.class)
public class TestSampleCompareTo {
- private final long thisCount;
- private final long otherCount;
- private final int compareResult;
-
- public TestSampleCompareTo(long thisCount, long otherCount,
- int compareResult) {
- this.thisCount = thisCount;
- this.otherCount = otherCount;
- this.compareResult = compareResult;
- }
-
- @Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] { { 0L, 0L, 0 }, { 1L, 0L, 1 },
- { 0L, 1L, -1 }, { Long.MAX_VALUE, Long.MIN_VALUE, 1 },
- { Long.MIN_VALUE, Long.MAX_VALUE, -1 }, { 1000L, -1000L, 1 },
- { -1000L, 1000L, -1 }, { Long.MIN_VALUE, Long.MIN_VALUE, 0 },
- { Long.MAX_VALUE, Long.MAX_VALUE, 0 } });
+ private static Stream<Arguments> data() {
+ return Stream.of(
+ Arguments.of(0L, 0L, 0),
+ Arguments.of(1L, 0L, 1),
+ Arguments.of(0L, 1L, -1),
+ Arguments.of(Long.MAX_VALUE, Long.MIN_VALUE, 1),
+ Arguments.of(Long.MIN_VALUE, Long.MAX_VALUE, -1),
+ Arguments.of(1000L, -1000L, 1),
+ Arguments.of(-1000L, 1000L, -1),
+ Arguments.of(Long.MIN_VALUE, Long.MIN_VALUE, 0),
+ Arguments.of(Long.MAX_VALUE, Long.MAX_VALUE, 0));
}
- @Test
- public void testCompareTo() {
+ @ParameterizedTest
+ @MethodSource("data")
+ void testCompareTo(long thisCount, long otherCount, int compareResult) {
assertThat(sample(thisCount).compareTo(sample(otherCount)),
CoreMatchers.is(compareResult));
}
diff --git a/src/core/src/test/java/org/apache/jmeter/samplers/TestDataStrippingSampleSender.java b/src/core/src/test/java/org/apache/jmeter/samplers/TestDataStrippingSampleSender.java
index 7e03d54..b605ca2 100644
--- a/src/core/src/test/java/org/apache/jmeter/samplers/TestDataStrippingSampleSender.java
+++ b/src/core/src/test/java/org/apache/jmeter/samplers/TestDataStrippingSampleSender.java
@@ -25,41 +25,32 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.test.JMeterSerialTest;
import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
-@RunWith(Parameterized.class)
public class TestDataStrippingSampleSender extends JMeterTestCase implements JMeterSerialTest {
private static final String TEST_CONTENT = "Something important";
- @Parameters(name = "is successful sample: {0}, expected content after stripping: {1}, stripOnFailure: {2}")
- public static Collection<Object[]> parameters() {
- return Arrays.asList(
- new Object[] {TRUE, "", TRUE},
- new Object[] {TRUE, "", FALSE},
- new Object[] {FALSE, "", TRUE},
- new Object[] {FALSE, TEST_CONTENT, FALSE}
+ private static Stream<Arguments> parameters() {
+ return Stream.of(
+ Arguments.of(TRUE, "", TRUE),
+ Arguments.of(TRUE, "", FALSE),
+ Arguments.of(FALSE, "", TRUE),
+ Arguments.of(FALSE, TEST_CONTENT, FALSE)
);
}
- @Parameter(0) public Boolean successfulParent;
- @Parameter(1) public String content;
- @Parameter(2) public Boolean stripOnError;
-
-
- @Test
- public void testSampleOccurred() throws IOException {
+ @ParameterizedTest(name = "{index}: is successful sample: {0}, expected content after stripping: {1}, stripOnFailure: {2}")
+ @MethodSource("parameters")
+ void testSampleOccurred(boolean successfulParent, String content, Boolean stripOnError) throws IOException {
Path props = Files.createTempFile("mydummy", ".properties");
JMeterUtils.loadJMeterProperties(props.toString());
JMeterUtils.getJMeterProperties().setProperty("sample_sender_strip_also_on_error", stripOnError.toString());
diff --git a/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java b/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
index ece1cbf..a87999e 100644
--- a/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
+++ b/src/core/src/test/java/org/apache/jmeter/util/SecurityProviderLoaderTest.java
@@ -25,8 +25,8 @@ import java.util.Arrays;
import java.util.Properties;
import org.junit.Assert;
-import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
@@ -34,7 +34,7 @@ import org.junit.jupiter.params.provider.ValueSource;
public class SecurityProviderLoaderTest {
@AfterEach
- public void removeAllDummyProviders() {
+ void removeAllDummyProviders() {
Security.removeProvider(DummyProvider.PROVIDER_NAME);
Security.removeProvider(DummyProviderWithConfig.PROVIDER_NAME);
Assert.assertNull(Security.getProvider(DummyProvider.PROVIDER_NAME));
@@ -42,7 +42,7 @@ public class SecurityProviderLoaderTest {
}
@Test
- public void utilityClassTest() throws Exception {
+ void utilityClassTest() throws Exception {
Constructor<SecurityProviderLoader> privateConstructor = SecurityProviderLoader.class.getDeclaredConstructor();
privateConstructor.setAccessible(true);
try {
@@ -53,7 +53,7 @@ public class SecurityProviderLoaderTest {
}
@Test
- public void addSecurityProviderTest() {
+ void addSecurityProviderTest() {
removeAllDummyProviders();
Provider[] providers = Security.getProviders();
int providersCountBefore = providers.length;
@@ -74,7 +74,7 @@ public class SecurityProviderLoaderTest {
}
@Test
- public void addSecurityProviderTestWithConfigForUnconfigurableProvider() {
+ void addSecurityProviderTestWithConfigForUnconfigurableProvider() {
removeAllDummyProviders();
int providersCountBefore = Security.getProviders().length;
@@ -91,7 +91,7 @@ public class SecurityProviderLoaderTest {
@ParameterizedTest
@ValueSource(strings = {"", "java.lang.Object", "org.apache.jmeter.util.SecurityProviderLoaderTest.UnknownProvider"})
- public void addInvalidProviderClassTest(String invalidClassname) {
+ void addInvalidProviderClassTest(String invalidClassname) {
removeAllDummyProviders();
int providersCountBefore = Security.getProviders().length;
@@ -104,7 +104,7 @@ public class SecurityProviderLoaderTest {
@ParameterizedTest
@ValueSource(ints = {0, 1, 2, 3})
- public void addSecurityProviderWithPositionTest(int position) {
+ void addSecurityProviderWithPositionTest(int position) {
removeAllDummyProviders();
int providersCountBefore = Security.getProviders().length;
@@ -128,7 +128,7 @@ public class SecurityProviderLoaderTest {
@ParameterizedTest
@CsvSource({":0:TestConfig,0", ":2:TEST,2", ":3:TEST,3"})
- public void addSecurityProviderWithPositionAndConfigTest(String config, int position) {
+ void addSecurityProviderWithPositionAndConfigTest(String config, int position) {
removeAllDummyProviders();
int providersCountBefore = Security.getProviders().length;
@@ -145,7 +145,7 @@ public class SecurityProviderLoaderTest {
}
@Test
- public void addSecurityProvidersViaProperties() {
+ void addSecurityProvidersViaProperties() {
removeAllDummyProviders();
int providersCountBefore = Security.getProviders().length;
@@ -171,7 +171,7 @@ public class SecurityProviderLoaderTest {
Assert.assertEquals("CONFIG", ((DummyProviderWithConfig) providerWithConfig).getConfig());
}
- public static class DummyProvider extends Provider {
+ static class DummyProvider extends Provider {
private static final long serialVersionUID = 1L;
public static final String PROVIDER_NAME = "DUMMY";
@@ -182,7 +182,7 @@ public class SecurityProviderLoaderTest {
}
- public static class DummyProviderWithConfig extends Provider {
+ static class DummyProviderWithConfig extends Provider {
private static final long serialVersionUID = 1L;
public static final String PROVIDER_NAME = "DUMMY_CONFIG";
diff --git a/src/jorphan/src/test/java/org/apache/jorphan/gui/MinMaxLongRendererTest.java b/src/jorphan/src/test/java/org/apache/jorphan/gui/MinMaxLongRendererTest.java
index dbb7f33..16c2eae 100644
--- a/src/jorphan/src/test/java/org/apache/jorphan/gui/MinMaxLongRendererTest.java
+++ b/src/jorphan/src/test/java/org/apache/jorphan/gui/MinMaxLongRendererTest.java
@@ -17,41 +17,30 @@
package org.apache.jorphan.gui;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Stream;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
-@RunWith(Parameterized.class)
public class MinMaxLongRendererTest {
- @Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] {
- {Long.MAX_VALUE, "#N/A" },
- {Long.MIN_VALUE, "#N/A" },
- {0L, "0" },
- { null, "#N/A" },
- { "invalid", "#N/A" },
- });
+ private static Stream<Arguments> data() {
+ return Stream.of(
+ Arguments.of(Long.MAX_VALUE, "#N/A"),
+ Arguments.of(Long.MIN_VALUE, "#N/A"),
+ Arguments.of(0L, "0"),
+ Arguments.of(null, "#N/A"),
+ Arguments.of("invalid", "#N/A")
+ );
}
- private final Object value;
- private final String expected;
-
- public MinMaxLongRendererTest(Object value, String expected) {
- this.value = value;
- this.expected = expected;
- }
-
- @Test
- public void testRendering() {
+ @ParameterizedTest
+ @MethodSource("data")
+ void testRendering(Object value, String expected) {
final AtomicBoolean afterInit = new AtomicBoolean(false);
MinMaxLongRenderer renderer = new MinMaxLongRenderer("#0") {
private static final long serialVersionUID = 2L;
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
index 4c9a8e2..ea8f020 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/SamplingNamingTest.java
@@ -19,38 +19,32 @@ package org.apache.jmeter.protocol.http.sampler;
import static org.junit.Assert.assertEquals;
+import java.util.stream.Stream;
+
import org.apache.jmeter.junit.JMeterTestCase;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jorphan.test.JMeterSerialTest;
import org.junit.Assert;
import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
-@RunWith(Parameterized.class)
public class SamplingNamingTest extends JMeterTestCase implements JMeterSerialTest {
private static final String JMETER_HOME_PAGE = "https://jmeter.apache.org";
private static final String LABEL = "JMeter-HP";
- private String implementation;
-
- public SamplingNamingTest(String implementation) {
- this.implementation = implementation;
- }
- @Parameters(name = "Run {index}: implementation:{0}")
- public static String[] getImplementations() {
- return new String[]{
- HTTPSamplerFactory.IMPL_HTTP_CLIENT4,
- HTTPSamplerFactory.IMPL_JAVA};
+ private static Stream<Arguments> getImplementations() {
+ return Stream.of(
+ Arguments.of(HTTPSamplerFactory.IMPL_HTTP_CLIENT4),
+ Arguments.of(HTTPSamplerFactory.IMPL_JAVA));
}
- @Test
+ @ParameterizedTest(name="Run {index}: implementation:{0}")
@Ignore(value = "Test produces: We should have at least one sample result, we had none too often")
- @Parameters(name = "getImplementations")
- public void testBug63364() {
+ @MethodSource("getImplementations")
+ void testBug63364(String implementation) {
TestPlan plan = new TestPlan();
SampleResult[] subResults = doSample(implementation);
Assert.assertTrue("We should have at least one sample result, we had none", subResults.length > 0);