This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
     new a5962eaa50 Code clean-up. No functional change.
a5962eaa50 is described below

commit a5962eaa50c1f1d0af945af574ffe3160536f7da
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 30 23:31:37 2023 +0100

    Code clean-up. No functional change.
---
 .../catalina/valves/rewrite/TestResolverSSL.java   |  12 +-
 .../catalina/valves/rewrite/TestRewriteValve.java  | 220 +++++++++------------
 .../catalina/valves/rewrite/TesterRewriteMapA.java |   2 +-
 3 files changed, 101 insertions(+), 133 deletions(-)

diff --git a/test/org/apache/catalina/valves/rewrite/TestResolverSSL.java 
b/test/org/apache/catalina/valves/rewrite/TestResolverSSL.java
index e426dacb51..6b7de8ef2c 100644
--- a/test/org/apache/catalina/valves/rewrite/TestResolverSSL.java
+++ b/test/org/apache/catalina/valves/rewrite/TestResolverSSL.java
@@ -49,10 +49,9 @@ public class TestResolverSSL extends TomcatBaseTest {
     @Parameterized.Parameters(name = "{0}")
     public static Collection<Object[]> parameters() {
         List<Object[]> parameterSets = new ArrayList<>();
-        parameterSets.add(new Object[] {
-                "JSSE", Boolean.FALSE, 
"org.apache.tomcat.util.net.jsse.JSSEImplementation"});
-        parameterSets.add(new Object[] {
-                "OpenSSL", Boolean.TRUE, 
"org.apache.tomcat.util.net.openssl.OpenSSLImplementation"});
+        parameterSets.add(new Object[] { "JSSE", Boolean.FALSE, 
"org.apache.tomcat.util.net.jsse.JSSEImplementation" });
+        parameterSets.add(
+                new Object[] { "OpenSSL", Boolean.TRUE, 
"org.apache.tomcat.util.net.openssl.OpenSSLImplementation" });
 
         return parameterSets;
     }
@@ -84,6 +83,7 @@ public class TestResolverSSL extends TomcatBaseTest {
         Assert.assertTrue(res.toString().indexOf("OK") > 0);
     }
 
+    //@formatter:off
     // List from https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#envvars
     private static final String[] keys = {
             "HTTPS",
@@ -141,12 +141,12 @@ public class TestResolverSSL extends TomcatBaseTest {
             "SSL_SRP_USER",
             "SSL_SRP_USERINFO",
             "SSL_TLS_SNI" };
+    //@formatter:on
 
     public static class ResolverTestValve extends ValveBase {
 
         @Override
-        public void invoke(Request request, Response response)
-                throws IOException, ServletException {
+        public void invoke(Request request, Response response) throws 
IOException, ServletException {
             PrintWriter writer = response.getWriter();
             Resolver resolver = new ResolverImpl(request);
             for (String key : keys) {
diff --git a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java 
b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
index 6a85de082d..d7eb88fe80 100644
--- a/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
+++ b/test/org/apache/catalina/valves/rewrite/TestRewriteValve.java
@@ -126,26 +126,22 @@ public class TestRewriteValve extends TomcatBaseTest {
 
     @Test
     public void testRewriteMap08() throws Exception {
-        doTestRewrite("RewriteMap lc int:tolower\n" +
-                "RewriteRule ^(.*) ${lc:$1}", "/C/AaA", "/c/aaa");
+        doTestRewrite("RewriteMap lc int:tolower\n" + "RewriteRule ^(.*) 
${lc:$1}", "/C/AaA", "/c/aaa");
     }
 
     @Test
     public void testRewriteMap09() throws Exception {
-        doTestRewrite("RewriteMap lc int:toupper\n" +
-            "RewriteRule ^(.*) ${lc:$1}", "/w/aAa", "/W/AAA");
+        doTestRewrite("RewriteMap lc int:toupper\n" + "RewriteRule ^(.*) 
${lc:$1}", "/w/aAa", "/W/AAA");
     }
 
     @Test
     public void testRewriteMap10() throws Exception {
-        doTestRewrite("RewriteMap lc int:escape\n" +
-            "RewriteRule ^(.*) ${lc:$1}", "/c/a%20aa", "/c/a%2520aa");
+        doTestRewrite("RewriteMap lc int:escape\n" + "RewriteRule ^(.*) 
${lc:$1}", "/c/a%20aa", "/c/a%2520aa");
     }
 
     @Test
     public void testRewriteMap11() throws Exception {
-        doTestRewrite("RewriteMap lc int:unescape\n" +
-            "RewriteRule ^(.*) ${lc:$1}", "/c/a%2520aa", "/c/a%20aa");
+        doTestRewrite("RewriteMap lc int:unescape\n" + "RewriteRule ^(.*) 
${lc:$1}", "/c/a%2520aa", "/c/a%20aa");
     }
 
 
@@ -158,86 +154,86 @@ public class TestRewriteValve extends TomcatBaseTest {
     @Test
     public void testRewriteMap12() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/a.html", "/c/aa");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/a.html", 
"/c/aa");
     }
 
     @Test
     public void testRewriteMap13() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1|dd}", "/b/x.html", 
"/c/dd");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1|dd}", "/b/x.html", 
"/c/dd");
     }
 
     // BZ 62667
     @Test
     public void testRewriteMap14() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1|d$1d}", "/b/x.html", 
"/c/dxd");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1|d$1d}", "/b/x.html", 
"/c/dxd");
     }
 
     @Test
     public void testRewriteMap15() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:a$1|dd}", "/b/a.html", 
"/c/aaaa");
+                "RewriteRule /b/(.*).html$ /c/${mapb:a$1|dd}", "/b/a.html", 
"/c/aaaa");
     }
 
     @Test
     public void testRewriteMap16() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt\n" +
-            "RewriteRule /b/.* /c/${mapb:a}", "/b/a.html", "/c/aa");
+                "RewriteRule /b/.* /c/${mapb:a}", "/b/a.html", "/c/aa");
     }
 
     @Test
     public void testRewriteMap17() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt\n" +
-            "RewriteRule /b/.* /c/${mapb:${mapb:a}}", "/b/a.html", "/c/aaaa");
+                "RewriteRule /b/.* /c/${mapb:${mapb:a}}", "/b/a.html", 
"/c/aaaa");
     }
 
     @Test
     public void testRewriteMap18() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt\n" +
-            "RewriteRule /b/.* /c/${mapb:${mapb:a}}", "/b/a.html", "/c/aaaa");
+                "RewriteRule /b/.* /c/${mapb:${mapb:a}}", "/b/a.html", 
"/c/aaaa");
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testRewriteMap19() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt first\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testRewriteMap20() throws Exception {
         doTestRewrite("RewriteMap mapb txt:" + getTestConfDirectory() + 
"TesterRewriteMapB.txt first second\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
     }
 
     @Test
     public void testRewriteMap21() throws Exception {
         doTestRewrite("RewriteMap mapb rnd:" + getTestConfDirectory() + 
"TesterRewriteMapC.txt\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/a.html", "/c/aa");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/a.html", 
"/c/aa");
     }
 
-    //This test should succeed 50% of the runs as it depends on a random choice
+    // This test should succeed 50% of the runs as it depends on a random 
choice
     public void testRewriteMap22() throws Exception {
         doTestRewrite("RewriteMap mapb rnd:" + getTestConfDirectory() + 
"TesterRewriteMapC.txt\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/b.html", "/c/bb");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/b.html", 
"/c/bb");
     }
 
     @Test
     public void testRewriteMap23() throws Exception {
         doTestRewrite("RewriteMap mapb rnd:" + getTestConfDirectory() + 
"TesterRewriteMapC.txt\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testRewriteMap24() throws Exception {
         doTestRewrite("RewriteMap mapb rnd:" + getTestConfDirectory() + 
"TesterRewriteMapC.txt first\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testRewriteMap25() throws Exception {
         doTestRewrite("RewriteMap mapb rnd:" + getTestConfDirectory() + 
"TesterRewriteMapC.txt first second\n" +
-            "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
+                "RewriteRule /b/(.*).html$ /c/${mapb:$1}", "/b/aa.html", 
"/c/aaaa");
     }
 
     @Test
@@ -248,15 +244,15 @@ public class TestRewriteValve extends TomcatBaseTest {
     @Test
     public void testRewriteEnvVarAndServerVar() throws Exception {
         System.setProperty("some_variable", "something");
-        doTestRewrite("RewriteRule /b/(.*).html$ 
/c/%{ENV:some_variable}%{SERVLET_PATH}",
-                "/b/x.html", "/c/something/b/x.html");
+        doTestRewrite("RewriteRule /b/(.*).html$ 
/c/%{ENV:some_variable}%{SERVLET_PATH}", "/b/x.html",
+                "/c/something/b/x.html");
     }
 
     @Test
     public void testRewriteServerVarAndEnvVar() throws Exception {
         System.setProperty("some_variable", "something");
-        doTestRewrite("RewriteRule /b/(.*).html$ 
/c%{SERVLET_PATH}/%{ENV:some_variable}",
-                "/b/x.html", "/c/b/x.html/something");
+        doTestRewrite("RewriteRule /b/(.*).html$ 
/c%{SERVLET_PATH}/%{ENV:some_variable}", "/b/x.html",
+                "/c/b/x.html/something");
     }
 
     @Test
@@ -281,8 +277,8 @@ public class TestRewriteValve extends TomcatBaseTest {
 
     // https://bz.apache.org/bugzilla/show_bug.cgi?id=60013
     public void testRewriteWithEncoding02() throws Exception {
-        doTestRewrite("RewriteRule ^/b/(.*)$ /c/?param=$1 [L]",
-                "/b/%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95", "/c/", 
"param=\u5728\u7EBF\u6D4B\u8BD5");
+        doTestRewrite("RewriteRule ^/b/(.*)$ /c/?param=$1 [L]", 
"/b/%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95", "/c/",
+                "param=\u5728\u7EBF\u6D4B\u8BD5");
     }
 
     @Test
@@ -293,8 +289,7 @@ public class TestRewriteValve extends TomcatBaseTest {
 
     @Test
     public void testNonAsciiPathRedirect() throws Exception {
-        doTestRewrite("RewriteRule ^/b/(.*) /c/$1 [R]",
-                "/b/%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95",
+        doTestRewrite("RewriteRule ^/b/(.*) /c/$1 [R]", 
"/b/%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95",
                 "/c/%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95");
     }
 
@@ -315,32 +310,28 @@ public class TestRewriteValve extends TomcatBaseTest {
 
     @Test
     public void testNonAsciiQueryString() throws Exception {
-        doTestRewrite("RewriteRule ^/b/(.*) /c?$1",
-                "/b/id=%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95",
-                "/c", "id=%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95");
+        doTestRewrite("RewriteRule ^/b/(.*) /c?$1", 
"/b/id=%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95", "/c",
+                "id=%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95");
     }
 
 
     @Test
     public void testNonAsciiQueryStringAndPath() throws Exception {
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/$1?$2",
-                "/b/%E5%9C%A8%E7%BA%BF/id=%E6%B5%8B%E8%AF%95",
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/$1?$2", 
"/b/%E5%9C%A8%E7%BA%BF/id=%E6%B5%8B%E8%AF%95",
                 "/c/%E5%9C%A8%E7%BA%BF", "id=%E6%B5%8B%E8%AF%95");
     }
 
 
     @Test
     public void testNonAsciiQueryStringAndRedirect() throws Exception {
-        doTestRewrite("RewriteRule ^/b/(.*) /c?$1 [R]",
-                "/b/id=%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95",
-                "/c", "id=%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95");
+        doTestRewrite("RewriteRule ^/b/(.*) /c?$1 [R]", 
"/b/id=%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95", "/c",
+                "id=%E5%9C%A8%E7%BA%BF%E6%B5%8B%E8%AF%95");
     }
 
 
     @Test
     public void testNonAsciiQueryStringAndPathAndRedirect() throws Exception {
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/$1?$2 [R]",
-                "/b/%E5%9C%A8%E7%BA%BF/id=%E6%B5%8B%E8%AF%95",
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/$1?$2 [R]", 
"/b/%E5%9C%A8%E7%BA%BF/id=%E6%B5%8B%E8%AF%95",
                 "/c/%E5%9C%A8%E7%BA%BF", "id=%E6%B5%8B%E8%AF%95");
     }
 
@@ -357,8 +348,7 @@ public class TestRewriteValve extends TomcatBaseTest {
     public void testNonAsciiQueryStringAndPathAndRedirectWithB() throws 
Exception {
         // Note the double encoding of the result (httpd produces the same 
result)
         doTestRewrite("RewriteRule ^/b/(.*)/(.*)/id=(.*) 
/c/$1?filename=$2&id=$3 [B,R]",
-                "/b/%E5%9C%A8%E7%BA%BF/file01/id=%E6%B5%8B%E8%AF%95",
-                "/c/%25E5%259C%25A8%25E7%25BA%25BF",
+                "/b/%E5%9C%A8%E7%BA%BF/file01/id=%E6%B5%8B%E8%AF%95", 
"/c/%25E5%259C%25A8%25E7%25BA%25BF",
                 "filename=file01&id=%25E6%25B5%258B%25E8%25AF%2595");
     }
 
@@ -366,32 +356,32 @@ public class TestRewriteValve extends TomcatBaseTest {
     @Test
     public void testUtf8WithBothQsFlagsNone() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%C2%A1", 
"id=%C2%A1");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%C2%A1",
+                "id=%C2%A1");
     }
 
 
     @Test
     public void testUtf8WithBothQsFlagsB() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [B]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%25C2%25A1", 
"id=%25C2%25A1");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [B]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE",
+                "/c/%C2%A1%25C2%25A1", "id=%25C2%25A1");
     }
 
 
     @Test
     public void testUtf8WithBothQsFlagsR() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%C2%A1", 
"id=%C2%A1");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE",
+                "/c/%C2%A1%C2%A1", "id=%C2%A1");
     }
 
 
     @Test
     public void testUtf8WithBothQsFlagsRB() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%25C2%25A1", 
"id=%25C2%25A1");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE",
+                "/c/%C2%A1%25C2%25A1", "id=%25C2%25A1");
     }
 
 
@@ -400,8 +390,7 @@ public class TestRewriteValve extends TomcatBaseTest {
         // Note %C2%A1 == \u00A1
         // Failing to escape the redirect means UTF-8 bytes in the Location
         // header which will be treated as if they are ISO-8859-1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,NE]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", null);
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,NE]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE", null);
     }
 
 
@@ -410,35 +399,31 @@ public class TestRewriteValve extends TomcatBaseTest {
         // Note %C2%A1 == \u00A1
         // Failing to escape the redirect means UTF-8 bytes in the Location
         // header which will be treated as if they are ISO-8859-1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B,NE]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", null);
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B,NE]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE", null);
     }
 
 
     @Test
     public void testUtf8WithBothQsFlagsBQSA() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [B,QSA]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%25C2%25A1",
-                "id=%25C2%25A1&di=%C2%AE");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [B,QSA]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE",
+                "/c/%C2%A1%25C2%25A1", "id=%25C2%25A1&di=%C2%AE");
     }
 
 
     @Test
     public void testUtf8WithBothQsFlagsRQSA() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,QSA]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%C2%A1",
-                "id=%C2%A1&di=%C2%AE");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,QSA]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE",
+                "/c/%C2%A1%C2%A1", "id=%C2%A1&di=%C2%AE");
     }
 
 
     @Test
     public void testUtf8WithBothQsFlagsRBQSA() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B,QSA]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%25C2%25A1",
-                "id=%25C2%25A1&di=%C2%AE");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B,QSA]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE",
+                "/c/%C2%A1%25C2%25A1", "id=%25C2%25A1&di=%C2%AE");
     }
 
 
@@ -447,8 +432,7 @@ public class TestRewriteValve extends TomcatBaseTest {
         // Note %C2%A1 == \u00A1
         // Failing to escape the redirect means UTF-8 bytes in the Location
         // header which will be treated as if they are ISO-8859-1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,NE,QSA]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", null);
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,NE,QSA]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE", null);
     }
 
 
@@ -457,40 +441,37 @@ public class TestRewriteValve extends TomcatBaseTest {
         // Note %C2%A1 == \u00A1
         // Failing to escape the redirect means UTF-8 bytes in the Location
         // header which will be treated as if they are ISO-8859-1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B,NE,QSA]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", null);
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B,NE,QSA]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE", null);
     }
 
 
     @Test
     public void testUtf8WithOriginalQsFlagsNone() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1",
-                "/b/%C2%A1?id=%C2%A1", "/c/%C2%A1%C2%A1", "id=%C2%A1");
+        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1", 
"/b/%C2%A1?id=%C2%A1", "/c/%C2%A1%C2%A1", "id=%C2%A1");
     }
 
 
     @Test
     public void testUtf8WithOriginalQsFlagsB() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [B]",
-                "/b/%C2%A1?id=%C2%A1", "/c/%C2%A1%25C2%25A1", "id=%C2%A1");
+        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [B]", 
"/b/%C2%A1?id=%C2%A1", "/c/%C2%A1%25C2%25A1",
+                "id=%C2%A1");
     }
 
 
     @Test
     public void testUtf8WithOriginalQsFlagsR() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [R]",
-                "/b/%C2%A1?id=%C2%A1", "/c/%C2%A1%C2%A1", "id=%C2%A1");
+        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [R]", 
"/b/%C2%A1?id=%C2%A1", "/c/%C2%A1%C2%A1", "id=%C2%A1");
     }
 
 
     @Test
     public void testUtf8WithOriginalQsFlagsRB() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [R,B]",
-                "/b/%C2%A1?id=%C2%A1", "/c/%C2%A1%25C2%25A1", "id=%C2%A1");
+        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [R,B]", 
"/b/%C2%A1?id=%C2%A1", "/c/%C2%A1%25C2%25A1",
+                "id=%C2%A1");
     }
 
 
@@ -499,8 +480,7 @@ public class TestRewriteValve extends TomcatBaseTest {
         // Note %C2%A1 == \u00A1
         // Failing to escape the redirect means UTF-8 bytes in the Location
         // header which will be treated as if they are ISO-8859-1
-        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [R,NE]",
-                "/b/%C2%A1?id=%C2%A1", null);
+        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [R,NE]", 
"/b/%C2%A1?id=%C2%A1", null);
     }
 
 
@@ -509,49 +489,47 @@ public class TestRewriteValve extends TomcatBaseTest {
         // Note %C2%A1 == \u00A1
         // Failing to escape the redirect means UTF-8 bytes in the Location
         // header which will be treated as if they are ISO-8859-1
-        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [R,B,NE]",
-                "/b/%C2%A1?id=%C2%A1", null);
+        doTestRewrite("RewriteRule ^/b/(.*) /c/\u00A1$1 [R,B,NE]", 
"/b/%C2%A1?id=%C2%A1", null);
     }
 
 
     @Test
     public void testUtf8WithRewriteQsFlagsNone() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2",
-                "/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%C2%A1", "id=%C2%A1");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2", 
"/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%C2%A1",
+                "id=%C2%A1");
     }
 
 
     @Test
     public void testUtf8WithRewriteQsFlagsB() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [B]",
-                "/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%25C2%25A1", "id=%25C2%25A1");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [B]", 
"/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%25C2%25A1",
+                "id=%25C2%25A1");
     }
 
 
     @Test
     public void testUtf8WithRewriteQsFlagsR() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R]",
-                "/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%C2%A1", "id=%C2%A1");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R]", 
"/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%C2%A1",
+                "id=%C2%A1");
     }
 
 
     @Test
     public void testUtf8WithBothQsFlagsQSA() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [QSA]",
-                "/b/%C2%A1/id=%C2%A1?di=%C2%AE", "/c/%C2%A1%C2%A1",
-                "id=%C2%A1&di=%C2%AE");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [QSA]", 
"/b/%C2%A1/id=%C2%A1?di=%C2%AE",
+                "/c/%C2%A1%C2%A1", "id=%C2%A1&di=%C2%AE");
     }
 
 
     @Test
     public void testUtf8WithRewriteQsFlagsRB() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B]",
-                "/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%25C2%25A1", "id=%25C2%25A1");
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B]", 
"/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%25C2%25A1",
+                "id=%25C2%25A1");
     }
 
 
@@ -560,8 +538,7 @@ public class TestRewriteValve extends TomcatBaseTest {
         // Note %C2%A1 == \u00A1
         // Failing to escape the redirect means UTF-8 bytes in the Location
         // header which will be treated as if they are ISO-8859-1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,NE]",
-                "/b/%C2%A1/id=%C2%A1", null);
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,NE]", 
"/b/%C2%A1/id=%C2%A1", null);
     }
 
 
@@ -570,16 +547,14 @@ public class TestRewriteValve extends TomcatBaseTest {
         // Note %C2%A1 == \u00A1
         // Failing to escape the redirect means UTF-8 bytes in the Location
         // header which will be treated as if they are ISO-8859-1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B,NE]",
-                "/b/%C2%A1/id=%C2%A1", null);
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [R,B,NE]", 
"/b/%C2%A1/id=%C2%A1", null);
     }
 
 
     @Test
     public void testUtf8WithRewriteQsFlagsQSA() throws Exception {
         // Note %C2%A1 == \u00A1
-        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [QSA]",
-                "/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%C2%A1",
+        doTestRewrite("RewriteRule ^/b/(.*)/(.*) /c/\u00A1$1?$2 [QSA]", 
"/b/%C2%A1/id=%C2%A1", "/c/%C2%A1%C2%A1",
                 "id=%C2%A1");
     }
 
@@ -633,9 +608,8 @@ public class TestRewriteValve extends TomcatBaseTest {
     @Test
     public void testFlagsNC() throws Exception {
         // https://bz.apache.org/bugzilla/show_bug.cgi?id=60116
-        doTestRewrite("RewriteCond %{QUERY_STRING} a=([a-z]*) [NC]\n"
-                + "RewriteRule .* - [E=X-Test:%1]",
-                    "/c?a=aAa", "/c", null, "aAa");
+        doTestRewrite("RewriteCond %{QUERY_STRING} a=([a-z]*) [NC]\n" + 
"RewriteRule .* - [E=X-Test:%1]", "/c?a=aAa",
+                "/c", null, "aAa");
     }
 
 
@@ -643,33 +617,29 @@ public class TestRewriteValve extends TomcatBaseTest {
     public void testHostRewrite() throws Exception {
         // Based on report from users list that ':' was encoded and breaking
         // the redirect
-        doTestRewrite("RewriteRule ^/b(.*) 
http://%{HTTP_HOST}:%{SERVER_PORT}/a$1 [R]",
-                "/b/%255A", "/a/%255A");
+        doTestRewrite("RewriteRule ^/b(.*) 
http://%{HTTP_HOST}:%{SERVER_PORT}/a$1 [R]", "/b/%255A", "/a/%255A");
     }
 
 
     @Test
     public void testDefaultRedirect() throws Exception {
-        doTestRedirect("RewriteRule ^/from/a$ /to/b [R]", "/redirect/from/a", 
"/redirect/to/b",
-                302);
+        doTestRedirect("RewriteRule ^/from/a$ /to/b [R]", "/redirect/from/a", 
"/redirect/to/b", 302);
     }
 
 
     @Test
     public void testTempRedirect() throws Exception {
-        doTestRedirect("RewriteRule ^/from/a$ /to/b [R=temp]", 
"/redirect/from/a", "/redirect/to/b",
-                302);
+        doTestRedirect("RewriteRule ^/from/a$ /to/b [R=temp]", 
"/redirect/from/a", "/redirect/to/b", 302);
     }
 
 
     @Test
     public void testPermanentRedirect() throws Exception {
-         // Disable the following of redirects for this test only
+        // Disable the following of redirects for this test only
         boolean originalValue = HttpURLConnection.getFollowRedirects();
         HttpURLConnection.setFollowRedirects(false);
         try {
-            doTestRedirect("RewriteRule ^/from/a$ /to/b [R=permanent]", 
"/redirect/from/a", "/redirect/to/b",
-                301);
+            doTestRedirect("RewriteRule ^/from/a$ /to/b [R=permanent]", 
"/redirect/from/a", "/redirect/to/b", 301);
         } finally {
             HttpURLConnection.setFollowRedirects(originalValue);
         }
@@ -678,12 +648,11 @@ public class TestRewriteValve extends TomcatBaseTest {
 
     @Test
     public void testSeeotherRedirect() throws Exception {
-         // Disable the following of redirects for this test only
+        // Disable the following of redirects for this test only
         boolean originalValue = HttpURLConnection.getFollowRedirects();
         HttpURLConnection.setFollowRedirects(false);
         try {
-            doTestRedirect("RewriteRule ^/from/a$ /to/b [R=seeother]", 
"/redirect/from/a", "/redirect/to/b",
-                303);
+            doTestRedirect("RewriteRule ^/from/a$ /to/b [R=seeother]", 
"/redirect/from/a", "/redirect/to/b", 303);
         } finally {
             HttpURLConnection.setFollowRedirects(originalValue);
         }
@@ -692,12 +661,11 @@ public class TestRewriteValve extends TomcatBaseTest {
 
     @Test
     public void test307Redirect() throws Exception {
-         // Disable the following of redirects for this test only
+        // Disable the following of redirects for this test only
         boolean originalValue = HttpURLConnection.getFollowRedirects();
         HttpURLConnection.setFollowRedirects(false);
         try {
-            doTestRedirect("RewriteRule ^/from/a$ /to/b [R=307]", 
"/redirect/from/a", "/redirect/to/b",
-                307);
+            doTestRedirect("RewriteRule ^/from/a$ /to/b [R=307]", 
"/redirect/from/a", "/redirect/to/b", 307);
         } finally {
             HttpURLConnection.setFollowRedirects(originalValue);
         }
@@ -754,14 +722,14 @@ public class TestRewriteValve extends TomcatBaseTest {
     }
 
 
-    private void doTestRewrite(String config, String request, String 
expectedURI,
-            String expectedQueryString) throws Exception {
+    private void doTestRewrite(String config, String request, String 
expectedURI, String expectedQueryString)
+            throws Exception {
         doTestRewrite(config, request, expectedURI, expectedQueryString, null);
     }
 
 
-    private void doTestRewrite(String config, String request, String 
expectedURI,
-            String expectedQueryString, String expectedAttributeValue) throws 
Exception {
+    private void doTestRewrite(String config, String request, String 
expectedURI, String expectedQueryString,
+            String expectedAttributeValue) throws Exception {
 
         Tomcat tomcat = getTomcatInstance();
 
@@ -808,8 +776,8 @@ public class TestRewriteValve extends TomcatBaseTest {
         }
     }
 
-    private void doTestRedirect(String config, String request, String 
expectedURI,
-        int expectedStatusCode) throws Exception {
+    private void doTestRedirect(String config, String request, String 
expectedURI, int expectedStatusCode)
+            throws Exception {
 
         Tomcat tomcat = getTomcatInstance();
 
@@ -829,8 +797,8 @@ public class TestRewriteValve extends TomcatBaseTest {
 
         ByteChunk res = new ByteChunk();
         Map<String, List<String>> resHead = new HashMap<>();
-        int rc = methodUrl("http://localhost:"; + getPort() + request, res,
-                DEFAULT_CLIENT_TIMEOUT_MS, null, resHead, "GET", false);
+        int rc = methodUrl("http://localhost:"; + getPort() + request, res, 
DEFAULT_CLIENT_TIMEOUT_MS, null, resHead,
+                "GET", false);
         res.setCharset(StandardCharsets.UTF_8);
 
         if (expectedURI == null) {
@@ -871,10 +839,10 @@ public class TestRewriteValve extends TomcatBaseTest {
         Map<String, List<String>> reqHead = new HashMap<>();
         reqHead.put("cookie", List.of("test=data"));
         ByteChunk res = new ByteChunk();
-        int rc = methodUrl("http://localhost:"; + getPort() + 
"/source/cookieTest", res,
-                DEFAULT_CLIENT_TIMEOUT_MS, reqHead, null, "GET", false);
+        int rc = methodUrl("http://localhost:"; + getPort() + 
"/source/cookieTest", res, DEFAULT_CLIENT_TIMEOUT_MS,
+                reqHead, null, "GET", false);
 
-        Assert.assertEquals(HttpServletResponse.SC_OK , rc);
+        Assert.assertEquals(HttpServletResponse.SC_OK, rc);
 
         res.setCharset(StandardCharsets.UTF_8);
         Assert.assertEquals("PASS", res.toString());
diff --git a/test/org/apache/catalina/valves/rewrite/TesterRewriteMapA.java 
b/test/org/apache/catalina/valves/rewrite/TesterRewriteMapA.java
index 0e0c5ccc53..434e3414d3 100644
--- a/test/org/apache/catalina/valves/rewrite/TesterRewriteMapA.java
+++ b/test/org/apache/catalina/valves/rewrite/TesterRewriteMapA.java
@@ -21,7 +21,7 @@ import java.util.Map;
 
 public class TesterRewriteMapA implements RewriteMap {
 
-    private static final Map<String,String> map = new HashMap<>();
+    private static final Map<String, String> map = new HashMap<>();
 
     static {
         map.put("a", "aa");


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to