Skip to content

Commit

Permalink
Fix IDE warnings. Reformat code.
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Dec 11, 2024
1 parent c60b2e8 commit 3700599
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public String value() {
}

protected List<String> genETagCondtion(String strongETag, String weakETag, IfPolicy policy) {
List<String> headerValues = new ArrayList<String>();
List<String> headerValues = new ArrayList<>();
switch (policy) {
case ETAG_ALL:
headerValues.add("*");
Expand All @@ -443,10 +443,10 @@ protected List<String> 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:
Expand All @@ -460,7 +460,7 @@ protected List<String> genETagCondtion(String strongETag, String weakETag, IfPol
}

protected List<String> genDateCondtion(long lastModifiedTimestamp, IfPolicy policy) {
List<String> headerValues = new ArrayList<String>();
List<String> headerValues = new ArrayList<>();
if (lastModifiedTimestamp <= 0) {
return headerValues;
}
Expand Down Expand Up @@ -494,7 +494,7 @@ protected void wrapperHeaders(Map<String,List<String>> headers, String resourceE
if (policy == null) {
return;
}
List<String> headerValues = new ArrayList<String>();
List<String> headerValues = new ArrayList<>();
String weakETag = resourceETag;
String strongETag = resourceETag;
if (resourceETag != null) {
Expand Down Expand Up @@ -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<String,List<String>> e : requestHeaders.entrySet()) {
for (String v : e.getValue()) {
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,45 +74,45 @@ public class TestDefaultServletRfc9110Section13Parameterized extends TomcatBaseT
public static Collection<Object[]> parameters() {
List<Object[]> 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;
Expand Down Expand Up @@ -205,7 +205,7 @@ public String value() {
}

protected List<String> genETagCondtion(String strongETag, String weakETag, IfPolicy policy) {
List<String> headerValues = new ArrayList<String>();
List<String> headerValues = new ArrayList<>();
switch (policy) {
case ETAG_ALL:
headerValues.add("*");
Expand Down Expand Up @@ -242,7 +242,7 @@ protected List<String> genETagCondtion(String strongETag, String weakETag, IfPol
}

protected List<String> genDateCondtion(long lastModifiedTimestamp, IfPolicy policy) {
List<String> headerValues = new ArrayList<String>();
List<String> headerValues = new ArrayList<>();
if (lastModifiedTimestamp <= 0) {
return headerValues;
}
Expand Down Expand Up @@ -276,7 +276,7 @@ protected void wrapperHeaders(Map<String,List<String>> headers, String resourceE
if (policy == null) {
return;
}
List<String> headerValues = new ArrayList<String>();
List<String> headerValues = new ArrayList<>();
String weakETag = resourceETag;
String strongETag = resourceETag;
if (resourceETag != null) {
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 3700599

Please sign in to comment.