From 370059979a5e6f1d6e2c30288c1f639f4dbd2aa2 Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Wed, 11 Dec 2024 14:22:06 +0000 Subject: [PATCH] Fix IDE warnings. Reformat code. --- .../TestDefaultServletRfc9110Section13.java | 19 ++-- ...tServletRfc9110Section13Parameterized.java | 89 ++++++++++--------- 2 files changed, 55 insertions(+), 53 deletions(-) diff --git a/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13.java b/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13.java index f191e6f0275d..c02596cb7c50 100644 --- a/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13.java +++ b/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13.java @@ -423,7 +423,7 @@ public String value() { } protected List genETagCondtion(String strongETag, String weakETag, IfPolicy policy) { - List headerValues = new ArrayList(); + List headerValues = new ArrayList<>(); switch (policy) { case ETAG_ALL: headerValues.add("*"); @@ -443,10 +443,10 @@ protected List genETagCondtion(String strongETag, String weakETag, IfPol break; case ETAG_NOT_IN: if (weakETag != null && weakETag.length() > 8) { - headerValues.add(weakETag.substring(0, 3) + "XXXXX"+weakETag.substring(8)); + headerValues.add(weakETag.substring(0, 3) + "XXXXX" + weakETag.substring(8)); } if (strongETag != null && strongETag.length() > 6) { - headerValues.add(strongETag.substring(0, 1) + "XXXXX"+strongETag.substring(6)); + headerValues.add(strongETag.substring(0, 1) + "XXXXX" + strongETag.substring(6)); } break; case ETAG_SYNTAX_INVALID: @@ -460,7 +460,7 @@ protected List genETagCondtion(String strongETag, String weakETag, IfPol } protected List genDateCondtion(long lastModifiedTimestamp, IfPolicy policy) { - List headerValues = new ArrayList(); + List headerValues = new ArrayList<>(); if (lastModifiedTimestamp <= 0) { return headerValues; } @@ -494,7 +494,7 @@ protected void wrapperHeaders(Map> headers, String resourceE if (policy == null) { return; } - List headerValues = new ArrayList(); + List headerValues = new ArrayList<>(); String weakETag = resourceETag; String strongETag = resourceETag; if (resourceETag != null) { @@ -611,8 +611,8 @@ public boolean isResponseBodyOK() { }; client.setPort(getPort()); StringBuffer curl = new StringBuffer(); - curl.append(task.m.name() + " " + task.uri + " HTTP/1.1" + SimpleHttpClient.CRLF + "Host: localhost" + SimpleHttpClient.CRLF + - "Connection: Close" + SimpleHttpClient.CRLF); + curl.append(task.m.name() + " " + task.uri + " HTTP/1.1" + SimpleHttpClient.CRLF + "Host: localhost" + + SimpleHttpClient.CRLF + "Connection: Close" + SimpleHttpClient.CRLF); for (Entry> e : requestHeaders.entrySet()) { for (String v : e.getValue()) { @@ -651,8 +651,9 @@ public boolean isResponseBodyOK() { String scExpectation = usePredicate ? "IntPredicate" : Arrays.toString(scExpected); Assert.assertTrue( "Failure - sc expected:%s, sc actual:%d, %s, task:%s, \ntarget resource:(%s,%s), \nreq headers: %s, \nresp headers: %s" - .formatted(scExpectation, sc, message, task, etag, FastHttpDateFormat.formatDate(lastModified), - requestHeaders.toString(), responseHeaders.toString()), + .formatted(scExpectation, Integer.valueOf(sc), message, task, etag, + FastHttpDateFormat.formatDate(lastModified), requestHeaders.toString(), + responseHeaders.toString()), test); } diff --git a/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java b/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java index 192b9ffc75a6..e9cbb3fee76d 100644 --- a/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java +++ b/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java @@ -74,45 +74,45 @@ public class TestDefaultServletRfc9110Section13Parameterized extends TomcatBaseT public static Collection parameters() { List parameterSets = new ArrayList<>(); // testPreconditions_rfc9110_13_2_2_1_head0 - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_ALL, null, null, null, null, false, - null, new int[] { 200 } }); - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_EXACTLY, null, null, null, null, - false, null, new int[] { 200 } }); - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_IN, null, null, null, null, false, - null, new int[] { 200 } }); - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_NOT_IN, null, null, null, null, - false, null, new int[] { 412 } }); - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_SYNTAX_INVALID, null, null, null, - null, false, null, new int[] { 400 } }); - - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_ALL, null, null, null, null, false, - null, new int[] { 200 } }); - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_EXACTLY, null, null, null, null, - false, null, new int[] { 412 } }); - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_IN, null, null, null, null, false, - null, new int[] { 412 } }); - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_NOT_IN, null, null, null, null, - false, null, new int[] { 412 } }); - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_SYNTAX_INVALID, null, null, null, - null, false, null, new int[] { 400 } }); - - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_EQ, null, null, null, false, - null, new int[] { 200 } }); - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_LT, null, null, null, false, - null, new int[] { 412 } }); - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_GT, null, null, null, false, - null, new int[] { 200 } }); - parameterSets.add(new Object[] { true, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_MULTI_IN, null, null, null, - false, null, new int[] { 200 } }); - - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_EQ, null, null, null, false, - null, new int[] { 200 } }); - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_LT, null, null, null, false, - null, new int[] { 412 } }); - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_GT, null, null, null, false, - null, new int[] { 200 } }); - parameterSets.add(new Object[] { false, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_MULTI_IN, null, null, null, - false, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_ALL, null, null, null, null, + Boolean.FALSE, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_EXACTLY, null, null, null, + null, Boolean.FALSE, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_IN, null, null, null, null, + Boolean.FALSE, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_NOT_IN, null, null, null, + null, Boolean.FALSE, null, new int[] { 412 } }); + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_SYNTAX_INVALID, null, null, + null, null, Boolean.FALSE, null, new int[] { 400 } }); + + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_ALL, null, null, null, null, + Boolean.FALSE, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_EXACTLY, null, null, null, + null, Boolean.FALSE, null, new int[] { 412 } }); + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_IN, null, null, null, null, + Boolean.FALSE, null, new int[] { 412 } }); + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_NOT_IN, null, null, null, + null, Boolean.FALSE, null, new int[] { 412 } }); + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, IfPolicy.ETAG_SYNTAX_INVALID, null, null, + null, null, Boolean.FALSE, null, new int[] { 400 } }); + + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_EQ, null, null, null, + Boolean.FALSE, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_LT, null, null, null, + Boolean.FALSE, null, new int[] { 412 } }); + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_GT, null, null, null, + Boolean.FALSE, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_MULTI_IN, null, null, + null, Boolean.FALSE, null, new int[] { 200 } }); + + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_EQ, null, null, null, + Boolean.FALSE, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_LT, null, null, null, + Boolean.FALSE, null, new int[] { 412 } }); + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_GT, null, null, null, + Boolean.FALSE, null, new int[] { 200 } }); + parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, null, IfPolicy.DATE_MULTI_IN, null, null, + null, Boolean.FALSE, null, new int[] { 200 } }); return parameterSets; @@ -205,7 +205,7 @@ public String value() { } protected List genETagCondtion(String strongETag, String weakETag, IfPolicy policy) { - List headerValues = new ArrayList(); + List headerValues = new ArrayList<>(); switch (policy) { case ETAG_ALL: headerValues.add("*"); @@ -242,7 +242,7 @@ protected List genETagCondtion(String strongETag, String weakETag, IfPol } protected List genDateCondtion(long lastModifiedTimestamp, IfPolicy policy) { - List headerValues = new ArrayList(); + List headerValues = new ArrayList<>(); if (lastModifiedTimestamp <= 0) { return headerValues; } @@ -276,7 +276,7 @@ protected void wrapperHeaders(Map> headers, String resourceE if (policy == null) { return; } - List headerValues = new ArrayList(); + List headerValues = new ArrayList<>(); String weakETag = resourceETag; String strongETag = resourceETag; if (resourceETag != null) { @@ -426,8 +426,9 @@ public boolean isResponseBodyOK() { String scExpectation = usePredicate ? "IntPredicate" : Arrays.toString(scExpected); Assert.assertTrue( "Failure - sc expected:%s, sc actual:%d, task:%s, \ntarget resource:(%s,%s), \nreq headers: %s, \nresp headers: %s" - .formatted(scExpectation, sc, task, etag, FastHttpDateFormat.formatDate(lastModified), - requestHeaders.toString(), responseHeaders.toString()), + .formatted(scExpectation, Integer.valueOf(sc), task, etag, + FastHttpDateFormat.formatDate(lastModified), requestHeaders.toString(), + responseHeaders.toString()), test); } }