You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by vl...@apache.org on 2026/03/19 15:24:50 UTC
(jmeter) 02/03: refactor: address review feedback in TestRedirects
This is an automated email from the ASF dual-hosted git repository.
vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
commit b59236106e685793b5a75714957c2d67509b741d
Author: LeeJiWon <dl...@gmail.com>
AuthorDate: Wed Mar 18 09:18:25 2026 +0900
refactor: address review feedback in TestRedirects
- Inline shouldRedirect variable directly into Arguments.of()
- Use Java 17 switch expression for expectedMethod computation
---
.../jmeter/protocol/http/sampler/TestRedirects.java | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestRedirects.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestRedirects.java
index 0a1a0e8f83..d95cf042e4 100644
--- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestRedirects.java
+++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestRedirects.java
@@ -48,8 +48,7 @@ class TestRedirects {
Arrays.stream(HTTPSamplerFactory.getImplementations()).forEach(httpImpl -> {
for (int statusCode : Arrays.asList(301, 302, 303, 307, 308)) {
for (String method : httpMethods) {
- boolean shouldRedirect = true;
- res.add(Arguments.of(httpImpl, statusCode, shouldRedirect, method));
+ res.add(Arguments.of(httpImpl, statusCode, true, method));
}
}
for (int statusCode : Arrays.asList(300, 304, 305, 306)) {
@@ -91,14 +90,10 @@ class TestRedirects {
Arrays.stream(HTTPSamplerFactory.getImplementations()).forEach(httpImpl -> {
for (int statusCode : Arrays.asList(301, 302, 303, 307, 308)) {
for (String method : httpMethods) {
- String expectedMethod;
- if (statusCode == 307 || statusCode == 308) {
- expectedMethod = method;
- } else if ("HEAD".equals(method)) {
- expectedMethod = "HEAD";
- } else {
- expectedMethod = "GET";
- }
+ String expectedMethod = switch (statusCode) {
+ case 307, 308 -> method;
+ default -> "HEAD".equals(method) ? "HEAD" : "GET";
+ };
res.add(Arguments.of(httpImpl, statusCode, method, expectedMethod));
}
}