(tomcat) branch 11.0.x updated: Use constants

2026-04-07 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
 new fc628e8b12 Use constants
fc628e8b12 is described below

commit fc628e8b12722521ceb406896f9a989ffa80ebd6
Author: Mark Thomas 
AuthorDate: Tue Apr 7 19:03:27 2026 +0100

Use constants
---
 .../catalina/filters/TestRateLimitFilter.java  | 19 --
 .../TestRateLimitFilterWithExactRateLimiter.java   | 23 ++
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/test/org/apache/catalina/filters/TestRateLimitFilter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilter.java
index 74a1ecae38..da715c63e0 100644
--- a/test/org/apache/catalina/filters/TestRateLimitFilter.java
+++ b/test/org/apache/catalina/filters/TestRateLimitFilter.java
@@ -23,6 +23,7 @@ import java.time.Instant;
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.FilterConfig;
 import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletResponse;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -79,16 +80,22 @@ public class TestRateLimitFilter extends TomcatBaseTest {
 count++;
 }
 
-Assert.assertEquals(200, tc1.results[24]); // only 25 requests made, 
all allowed
+// only 25 requests made, all allowed
+Assert.assertEquals(HttpServletResponse.SC_OK, tc1.results[24]);
 
-Assert.assertEquals(200, tc2.results[49]); // only 25 requests made, 
all allowed
+// only 25 requests made, all allowed
+Assert.assertEquals(HttpServletResponse.SC_OK, tc2.results[49]);
 
-Assert.assertEquals(200, tc3.results[allowedRequests - 1]); // first 
allowedRequests allowed
+// first allowedRequests allowed
+Assert.assertEquals(HttpServletResponse.SC_OK, 
tc3.results[allowedRequests - 1]);
 
-Assert.assertEquals(200, tc4.results[allowedRequests - 1]); // first 
allowedRequests allowed
+// first allowedRequests allowed
+Assert.assertEquals(HttpServletResponse.SC_OK, 
tc4.results[allowedRequests - 1]);
 if (enforce) {
-Assert.assertEquals(429, tc3.results[allowedRequests]); // 
subsequent requests dropped
-Assert.assertEquals(429, tc4.results[allowedRequests]); // 
subsequent requests dropped
+// subsequent requests dropped
+Assert.assertEquals(429, tc3.results[allowedRequests]);
+// subsequent requests dropped
+Assert.assertEquals(429, tc4.results[allowedRequests]);
 }
 if (exposeHeaders) {
 Assert.assertTrue(tc3.rlpHeader[24].contains("q=" + 
allowedRequests));
diff --git 
a/test/org/apache/catalina/filters/TestRateLimitFilterWithExactRateLimiter.java 
b/test/org/apache/catalina/filters/TestRateLimitFilterWithExactRateLimiter.java
index 90d3c048cc..49da66af8d 100644
--- 
a/test/org/apache/catalina/filters/TestRateLimitFilterWithExactRateLimiter.java
+++ 
b/test/org/apache/catalina/filters/TestRateLimitFilterWithExactRateLimiter.java
@@ -19,6 +19,7 @@ package org.apache.catalina.filters;
 import java.io.IOException;
 
 import jakarta.servlet.FilterChain;
+import jakarta.servlet.http.HttpServletResponse;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -69,24 +70,30 @@ public class TestRateLimitFilterWithExactRateLimiter 
extends TomcatBaseTest {
 tc2.join();
 tc3.join();
 tc4.join();
-Assert.assertEquals(200, tc1.results[24]); // only 25 requests made in 
5 seconds, all allowed
+// only 25 requests made in 5 seconds, all allowed
+Assert.assertEquals(HttpServletResponse.SC_OK, tc1.results[24]);
 
-Assert.assertEquals(200, tc2.results[49]); // only 50 requests made in 
5 seconds, all allowed
+// only 50 requests made in 5 seconds, all allowed
+Assert.assertEquals(HttpServletResponse.SC_OK, tc2.results[49]);
 
-Assert.assertEquals(200, tc3.results[39]); // first allowedRequests 
allowed
+// first allowedRequests allowed
+Assert.assertEquals(HttpServletResponse.SC_OK, tc3.results[39]);
 
 if (enforce) {
-Assert.assertEquals(429, tc3.results[allowedRequests]); // 
subsequent requests dropped
+// subsequent requests dropped
+Assert.assertEquals(429, tc3.results[allowedRequests]);
 } else {
-Assert.assertEquals(200, tc3.results[allowedRequests]);
+Assert.assertEquals(HttpServletResponse.SC_OK, 
tc3.results[allowedRequests]);
 }
 
-Assert.assertEquals(200, tc4.results[allowedRequests - 1]); // first 
allowedRequests allowed
+// first allowedRequests allowed
+Assert.assertEquals(HttpServletResponse.SC_OK, 
tc4.results[allowedRequests - 1]);
 
 if (enforce) {
-Assert.assertEquals(429, tc4.results[all

(tomcat) branch 11.0.x updated: Use constants. Update comments.

2025-01-31 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
 new 9a6e029c98 Use constants. Update comments.
9a6e029c98 is described below

commit 9a6e029c98b61731d280c3eb68f8cbf3e374dc6b
Author: Mark Thomas 
AuthorDate: Fri Jan 31 15:27:19 2025 +

Use constants. Update comments.
---
 test/org/apache/catalina/util/TestParameterMapPerformance.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/org/apache/catalina/util/TestParameterMapPerformance.java 
b/test/org/apache/catalina/util/TestParameterMapPerformance.java
index fe2ea9bf79..a89341a1a5 100644
--- a/test/org/apache/catalina/util/TestParameterMapPerformance.java
+++ b/test/org/apache/catalina/util/TestParameterMapPerformance.java
@@ -62,10 +62,10 @@ public class TestParameterMapPerformance {
 System.out.println("Done with standard in " + duration + "ms");
 }
 /*
- * The CI systems tend to produce outliers that lead to false failures 
so skip the longest two runs.
+ * The CI systems tend to produce outliers that lead to false failures 
so skip the longest NUM_SKIP runs.
  */
 long standardTotalDuration =
-standardDurations.stream().sorted().limit(NUM_TESTS - 
2).reduce(Long::sum).get().longValue();
+standardDurations.stream().sorted().limit(NUM_TESTS - 
NUM_SKIP).reduce(Long::sum).get().longValue();
 
 List optimizedDurations = new ArrayList<>();
 for (int i = 0; i < NUM_TESTS; i++) {
@@ -79,7 +79,7 @@ public class TestParameterMapPerformance {
 System.out.println("Done with optimized in " + duration + "ms");
 }
 /*
- * The CI systems tend to produce outliers that lead to false failures 
so skip the longest two runs.
+ * The CI systems tend to produce outliers that lead to false failures 
so skip the longest NUM_SKIP runs.
  */
 long optimizedTotalDuration =
 optimizedDurations.stream().sorted().limit(NUM_TESTS - 
NUM_SKIP).reduce(Long::sum).get().longValue();


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]