From 4cf01c298c783b3148358a7e96eae60850957848 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 | 23 +++-- ...tServletRfc9110Section13Parameterized.java | 91 +++++++++---------- 2 files changed, 56 insertions(+), 58 deletions(-) diff --git a/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13.java b/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13.java index f06543df0b31..624b0c3f3563 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()) { @@ -649,11 +649,10 @@ public boolean isResponseBodyOK() { test = p.test(sc); } String scExpectation = usePredicate ? "IntPredicate" : Arrays.toString(scExpected); - Assert.assertTrue( - "Failure - sc expected:" + scExpectation + ", sc actual:" + String.valueOf(sc) + ", " + message - + ", task:" + task + ", \ntarget resource:(" + etag + "," + FastHttpDateFormat.formatDate(lastModified) - + "), \nreq headers: " + requestHeaders.toString() + ", \nresp headers: " + responseHeaders.toString(), - test); + Assert.assertTrue("Failure - sc expected:" + scExpectation + ", sc actual:" + String.valueOf(sc) + ", " + + message + ", task:" + task + ", \ntarget resource:(" + etag + "," + + FastHttpDateFormat.formatDate(lastModified) + "), \nreq headers: " + requestHeaders.toString() + + ", \nresp headers: " + responseHeaders.toString(), test); } protected void testPreconditions(Task task, IfPolicy ifMatchHeader, IfPolicy ifUnmodifiedSinceHeader, diff --git a/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java b/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java index 018ad1ef5ac4..7388a976750e 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) { @@ -424,10 +424,9 @@ public boolean isResponseBodyOK() { test = p.test(sc); } String scExpectation = usePredicate ? "IntPredicate" : Arrays.toString(scExpected); - Assert.assertTrue( - "Failure - sc expected:" + scExpectation + ", sc actual:" + String.valueOf(sc) - + ", task:" + task + ", \ntarget resource:(" + etag + "," + FastHttpDateFormat.formatDate(lastModified) - + "), \nreq headers: " + requestHeaders.toString() + ", \nresp headers: " + responseHeaders.toString(), + Assert.assertTrue("Failure - sc expected:" + scExpectation + ", sc actual:" + String.valueOf(sc) + ", task:" + + task + ", \ntarget resource:(" + etag + "," + FastHttpDateFormat.formatDate(lastModified) + + "), \nreq headers: " + requestHeaders.toString() + ", \nresp headers: " + responseHeaders.toString(), test); } }