From 44a3b5cde4d621c5169ee1e0bed8d53c5a767da2 Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Thu, 12 Dec 2024 11:22:44 +0000 Subject: [PATCH] Reduce duplication --- ...tServletRfc9110Section13Parameterized.java | 68 +++++++------------ 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java b/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java index 88a0d46d9687..3347be5fbeda 100644 --- a/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java +++ b/test/org/apache/catalina/servlets/TestDefaultServletRfc9110Section13Parameterized.java @@ -68,49 +68,31 @@ public class TestDefaultServletRfc9110Section13Parameterized extends TomcatBaseT @Parameterized.Parameters(name = "{index} resource-strong [{0}], matchHeader [{1}]") public static Collection parameters() { List parameterSets = new ArrayList<>(); - // testPreconditions_rfc9110_13_2_2_1_head0 - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, EtagPrecondition.ALL, null, null, null, - null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, EtagPrecondition.EXACTLY, null, null, null, - null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, EtagPrecondition.IN, null, null, null, - null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, EtagPrecondition.NOT_IN, null, null, null, - null, Boolean.FALSE, SC_412 }); - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, EtagPrecondition.INVALID_ALL_PLUS_OTHER, - null, null, null, null, Boolean.FALSE, SC_400 }); - - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, EtagPrecondition.ALL, null, null, null, - null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, EtagPrecondition.EXACTLY, null, null, - null, null, Boolean.FALSE, SC_412 }); - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, EtagPrecondition.IN, null, null, null, - null, Boolean.FALSE, SC_412 }); - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, EtagPrecondition.NOT_IN, null, null, null, - null, Boolean.FALSE, SC_412 }); - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, EtagPrecondition.INVALID_ALL_PLUS_OTHER, - null, null, null, null, Boolean.FALSE, SC_400 }); - - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, DatePrecondition.EQ, null, null, - null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, DatePrecondition.LT, null, null, - null, Boolean.FALSE, SC_412 }); - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, DatePrecondition.GT, null, null, - null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, DatePrecondition.MULTI_IN, null, - null, null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.TRUE, Task.HEAD_INDEX_HTML, null, DatePrecondition.LT, null, - DatePrecondition.GT, null, Boolean.FALSE, SC_412 }); - - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, null, DatePrecondition.EQ, null, null, - null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, null, DatePrecondition.LT, null, null, - null, Boolean.FALSE, SC_412 }); - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, null, DatePrecondition.GT, null, null, - null, Boolean.FALSE, SC_200 }); - parameterSets.add(new Object[] { Boolean.FALSE, Task.HEAD_INDEX_HTML, null, DatePrecondition.MULTI_IN, null, - null, null, Boolean.FALSE, SC_200 }); - + for (Boolean useStrongEtag : booleans) { + // RFC 9110, Section 13.2.2, Step 1, HEAD + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, EtagPrecondition.ALL, null, null, null, + null, Boolean.FALSE, SC_200 }); + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, EtagPrecondition.EXACTLY, null, null, null, + null, Boolean.FALSE, useStrongEtag.booleanValue() ? SC_200 : SC_412}); + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, EtagPrecondition.IN, null, null, null, + null, Boolean.FALSE, useStrongEtag.booleanValue() ? SC_200 : SC_412 }); + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, EtagPrecondition.NOT_IN, null, null, null, + null, Boolean.FALSE, SC_412 }); + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, EtagPrecondition.INVALID_ALL_PLUS_OTHER, + null, null, null, null, Boolean.FALSE, SC_400 }); + + // RFC 9110, Section 13.2.2, Step 2, HEAD + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, null, DatePrecondition.EQ, null, null, + null, Boolean.FALSE, SC_200 }); + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, null, DatePrecondition.LT, null, null, + null, Boolean.FALSE, SC_412 }); + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, null, DatePrecondition.GT, null, null, + null, Boolean.FALSE, SC_200 }); + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, null, DatePrecondition.MULTI_IN, null, + null, null, Boolean.FALSE, SC_200 }); + parameterSets.add(new Object[] { useStrongEtag, Task.HEAD_INDEX_HTML, null, DatePrecondition.LT, null, + DatePrecondition.GT, null, Boolean.FALSE, SC_412 }); + } return parameterSets; }