You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/02/23 16:48:40 UTC
[tomcat] 06/06: Clean-up - formatting. No functional change.
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
commit 4cadeffb7821cf1fa7c13c2a87652d668e3ba7e1
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Feb 23 16:48:17 2023 +0000
Clean-up - formatting. No functional change.
---
test/org/apache/coyote/http2/Http2TestBase.java | 214 +++++++--------
test/org/apache/coyote/http2/TestAsync.java | 19 +-
test/org/apache/coyote/http2/TestAsyncFlush.java | 5 +-
test/org/apache/coyote/http2/TestAsyncTimeout.java | 3 +-
.../apache/coyote/http2/TestCancelledUpload.java | 27 +-
test/org/apache/coyote/http2/TestFlowControl.java | 20 +-
test/org/apache/coyote/http2/TestHpack.java | 8 +-
.../coyote/http2/TestHttp2InitialConnection.java | 40 ++-
test/org/apache/coyote/http2/TestHttp2Limits.java | 294 ++++++++++-----------
.../apache/coyote/http2/TestHttp2Section_3_2.java | 31 +--
.../apache/coyote/http2/TestHttp2Section_3_5.java | 4 +-
.../apache/coyote/http2/TestHttp2Section_4_1.java | 10 +-
.../apache/coyote/http2/TestHttp2Section_4_2.java | 14 +-
.../apache/coyote/http2/TestHttp2Section_4_3.java | 11 +-
.../apache/coyote/http2/TestHttp2Section_5_1.java | 55 ++--
.../apache/coyote/http2/TestHttp2Section_5_2.java | 13 +-
.../apache/coyote/http2/TestHttp2Section_5_5.java | 9 +-
.../apache/coyote/http2/TestHttp2Section_6_1.java | 50 ++--
.../apache/coyote/http2/TestHttp2Section_6_2.java | 13 +-
.../apache/coyote/http2/TestHttp2Section_6_3.java | 10 +-
.../apache/coyote/http2/TestHttp2Section_6_4.java | 10 +-
.../apache/coyote/http2/TestHttp2Section_6_5.java | 22 +-
.../apache/coyote/http2/TestHttp2Section_6_6.java | 5 +-
.../apache/coyote/http2/TestHttp2Section_6_7.java | 7 +-
.../apache/coyote/http2/TestHttp2Section_6_8.java | 11 +-
.../apache/coyote/http2/TestHttp2Section_6_9.java | 63 ++---
.../apache/coyote/http2/TestHttp2Section_8_1.java | 72 ++---
.../org/apache/coyote/http2/TestHttp2Timeouts.java | 10 +-
.../coyote/http2/TestHttp2UpgradeHandler.java | 46 +---
test/org/apache/coyote/http2/TestLargeUpload.java | 19 +-
test/org/apache/coyote/http2/TestStream.java | 32 +--
.../apache/coyote/http2/TestStreamProcessor.java | 26 +-
.../apache/coyote/http2/TestStreamQueryString.java | 45 +---
.../org/apache/coyote/http2/TesterHttp2Parser.java | 6 +-
34 files changed, 477 insertions(+), 747 deletions(-)
diff --git a/test/org/apache/coyote/http2/Http2TestBase.java b/test/org/apache/coyote/http2/Http2TestBase.java
index 60035c3434..df70095346 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -66,8 +66,7 @@ import org.apache.tomcat.util.http.parser.Priority;
import org.apache.tomcat.util.net.TesterSupport;
/**
- * Tests for compliance with the <a href="https://tools.ietf.org/html/rfc7540">
- * HTTP/2 specification</a>.
+ * Tests for compliance with the <a href="https://tools.ietf.org/html/rfc7540"> HTTP/2 specification</a>.
*/
@RunWith(Parameterized.class)
public abstract class Http2TestBase extends TomcatBaseTest {
@@ -101,8 +100,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
private static final String HEADER_IGNORED = "x-ignore";
static final String DEFAULT_CONNECTION_HEADER_VALUE = "Upgrade, HTTP2-Settings";
- private static final byte[] EMPTY_SETTINGS_FRAME =
- { 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ private static final byte[] EMPTY_SETTINGS_FRAME = { 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 };
static final String EMPTY_HTTP2_SETTINGS_HEADER;
static {
@@ -132,8 +130,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
/**
- * Standard setup. Creates HTTP/2 connection via HTTP upgrade and ensures
- * that the first response is correctly received.
+ * Standard setup. Creates HTTP/2 connection via HTTP upgrade and ensures that the first response is correctly
+ * received.
*/
protected void http2Connect() throws Exception {
http2Connect(false);
@@ -168,12 +166,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals("0-Settings-[3]-[" + maxConcurrentStreams + "]\n" +
- "0-Settings-End\n" +
- "0-Settings-Ack\n" +
- "0-Ping-[0,0,0,0,0,0,0,1]\n" +
- getSimpleResponseTrace(1)
- , output.getTrace());
+ Assert.assertEquals("0-Settings-[3]-[" + maxConcurrentStreams + "]\n" + "0-Settings-End\n" +
+ "0-Settings-Ack\n" + "0-Ping-[0,0,0,0,0,0,0,1]\n" + getSimpleResponseTrace(1), output.getTrace());
output.clearTrace();
}
@@ -210,14 +204,12 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void buildEmptyGetRequest(byte[] frameHeader, ByteBuffer headersPayload,
- byte[] padding, int streamId) {
+ protected void buildEmptyGetRequest(byte[] frameHeader, ByteBuffer headersPayload, byte[] padding, int streamId) {
buildGetRequest(frameHeader, headersPayload, padding, streamId, "/empty");
}
- protected void buildSimpleGetRequest(byte[] frameHeader, ByteBuffer headersPayload,
- byte[] padding, int streamId) {
+ protected void buildSimpleGetRequest(byte[] frameHeader, ByteBuffer headersPayload, byte[] padding, int streamId) {
buildGetRequest(frameHeader, headersPayload, padding, streamId, "/simple");
}
@@ -227,8 +219,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void buildGetRequest(byte[] frameHeader, ByteBuffer headersPayload, byte[] padding,
- int streamId, String url) {
+ protected void buildGetRequest(byte[] frameHeader, ByteBuffer headersPayload, byte[] padding, int streamId,
+ String url) {
List<Header> headers = new ArrayList<>(4);
headers.add(new Header(":method", "GET"));
headers.add(new Header(":scheme", "http"));
@@ -239,8 +231,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void buildGetRequest(byte[] frameHeader, ByteBuffer headersPayload, byte[] padding,
- List<Header> headers, int streamId) {
+ protected void buildGetRequest(byte[] frameHeader, ByteBuffer headersPayload, byte[] padding, List<Header> headers,
+ int streamId) {
if (padding != null) {
headersPayload.put((byte) (0xFF & padding.length));
}
@@ -266,8 +258,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void buildSimpleGetRequestPart1(byte[] frameHeader, ByteBuffer headersPayload,
- int streamId) {
+ protected void buildSimpleGetRequestPart1(byte[] frameHeader, ByteBuffer headersPayload, int streamId) {
List<Header> headers = new ArrayList<>(3);
headers.add(new Header(":method", "GET"));
headers.add(new Header(":scheme", "http"));
@@ -277,8 +268,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void buildSimpleGetRequestPart1(byte[] frameHeader, ByteBuffer headersPayload,
- List<Header> headers, int streamId) {
+ protected void buildSimpleGetRequestPart1(byte[] frameHeader, ByteBuffer headersPayload, List<Header> headers,
+ int streamId) {
MimeHeaders mimeHeaders = new MimeHeaders();
for (Header header : headers) {
mimeHeaders.addValue(header.getName()).setString(header.getValue());
@@ -296,8 +287,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void buildSimpleGetRequestPart2(byte[] frameHeader, ByteBuffer headersPayload,
- int streamId) {
+ protected void buildSimpleGetRequestPart2(byte[] frameHeader, ByteBuffer headersPayload, int streamId) {
List<Header> headers = new ArrayList<>(3);
headers.add(new Header(":authority", "localhost:" + getPort()));
@@ -305,8 +295,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void buildSimpleGetRequestPart2(byte[] frameHeader, ByteBuffer headersPayload,
- List<Header> headers, int streamId) {
+ protected void buildSimpleGetRequestPart2(byte[] frameHeader, ByteBuffer headersPayload, List<Header> headers,
+ int streamId) {
MimeHeaders mimeHeaders = new MimeHeaders();
for (Header header : headers) {
mimeHeaders.addValue(header.getName()).setString(header.getValue());
@@ -329,20 +319,19 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void sendSimplePostRequest(int streamId, byte[] padding, boolean writeBody)
- throws IOException {
+ protected void sendSimplePostRequest(int streamId, byte[] padding, boolean writeBody) throws IOException {
sendSimplePostRequest(streamId, padding, writeBody, false);
}
- protected void sendSimplePostRequest(int streamId, byte[] padding, boolean writeBody,
- boolean useExpectation) throws IOException {
+ protected void sendSimplePostRequest(int streamId, byte[] padding, boolean writeBody, boolean useExpectation)
+ throws IOException {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
byte[] dataFrameHeader = new byte[9];
ByteBuffer dataPayload = ByteBuffer.allocate(128);
- buildPostRequest(headersFrameHeader, headersPayload, useExpectation,
- dataFrameHeader, dataPayload, padding, streamId);
+ buildPostRequest(headersFrameHeader, headersPayload, useExpectation, dataFrameHeader, dataPayload, padding,
+ streamId);
writeFrame(headersFrameHeader, headersPayload);
if (writeBody) {
writeFrame(dataFrameHeader, dataPayload);
@@ -350,16 +339,15 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void sendParameterPostRequest(int streamId, byte[] padding, String body,
- long contentLength, boolean useExpectation) throws IOException {
+ protected void sendParameterPostRequest(int streamId, byte[] padding, String body, long contentLength,
+ boolean useExpectation) throws IOException {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
byte[] dataFrameHeader = new byte[9];
ByteBuffer dataPayload = ByteBuffer.allocate(128);
- buildPostRequest(headersFrameHeader, headersPayload, useExpectation,
- "application/x-www-form-urlencoded", contentLength, "/parameter", dataFrameHeader,
- dataPayload, padding, null, null, streamId);
+ buildPostRequest(headersFrameHeader, headersPayload, useExpectation, "application/x-www-form-urlencoded",
+ contentLength, "/parameter", dataFrameHeader, dataPayload, padding, null, null, streamId);
writeFrame(headersFrameHeader, headersPayload);
if (body != null) {
dataPayload.put(body.getBytes(StandardCharsets.ISO_8859_1));
@@ -368,24 +356,22 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPayload,
- boolean useExpectation, byte[] dataFrameHeader, ByteBuffer dataPayload, byte[] padding,
- int streamId) {
- buildPostRequest(headersFrameHeader, headersPayload, useExpectation, dataFrameHeader,
- dataPayload, padding, null, null, streamId);
+ protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPayload, boolean useExpectation,
+ byte[] dataFrameHeader, ByteBuffer dataPayload, byte[] padding, int streamId) {
+ buildPostRequest(headersFrameHeader, headersPayload, useExpectation, dataFrameHeader, dataPayload, padding,
+ null, null, streamId);
}
- protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPayload,
- boolean useExpectation, byte[] dataFrameHeader, ByteBuffer dataPayload, byte[] padding,
- byte[] trailersFrameHeader, ByteBuffer trailersPayload, int streamId) {
- buildPostRequest(headersFrameHeader, headersPayload, useExpectation, null, -1, "/simple",
- dataFrameHeader, dataPayload, padding, trailersFrameHeader, trailersPayload, streamId);
+ protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPayload, boolean useExpectation,
+ byte[] dataFrameHeader, ByteBuffer dataPayload, byte[] padding, byte[] trailersFrameHeader,
+ ByteBuffer trailersPayload, int streamId) {
+ buildPostRequest(headersFrameHeader, headersPayload, useExpectation, null, -1, "/simple", dataFrameHeader,
+ dataPayload, padding, trailersFrameHeader, trailersPayload, streamId);
}
- protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPayload,
- boolean useExpectation, String contentType, long contentLength, String path,
- byte[] dataFrameHeader, ByteBuffer dataPayload, byte[] padding,
- byte[] trailersFrameHeader, ByteBuffer trailersPayload, int streamId) {
+ protected void buildPostRequest(byte[] headersFrameHeader, ByteBuffer headersPayload, boolean useExpectation,
+ String contentType, long contentLength, String path, byte[] dataFrameHeader, ByteBuffer dataPayload,
+ byte[] padding, byte[] trailersFrameHeader, ByteBuffer trailersPayload, int streamId) {
MimeHeaders headers = new MimeHeaders();
headers.addValue(":method").setString("POST");
@@ -488,20 +474,17 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected void writeFrame(byte[] header, ByteBuffer payload)
- throws IOException {
+ protected void writeFrame(byte[] header, ByteBuffer payload) throws IOException {
writeFrame(header, payload, 0, payload.limit());
}
- protected void writeFrame(byte[] header, ByteBuffer payload, int offset, int len)
- throws IOException {
+ protected void writeFrame(byte[] header, ByteBuffer payload, int offset, int len) throws IOException {
writeFrame(header, payload, offset, len, 0);
}
- protected void writeFrame(byte[] header, ByteBuffer payload, int offset, int len, int delayms)
- throws IOException {
+ protected void writeFrame(byte[] header, ByteBuffer payload, int offset, int len, int delayms) throws IOException {
os.write(header);
os.write(payload.array(), payload.arrayOffset() + offset, len);
os.flush();
@@ -525,12 +508,10 @@ public abstract class Http2TestBase extends TomcatBaseTest {
protected void readSimplePostResponse(boolean padding) throws Http2Exception, IOException {
/*
- * If there is padding there will always be a window update for the
- * connection and, depending on timing, there may be an update for the
- * stream. The Window updates for padding (if present) may appear at any
- * time. The comments in the code below are only indicative of what the
- * frames are likely to contain. Actual frame order with padding may be
- * different.
+ * If there is padding there will always be a window update for the connection and, depending on timing, there
+ * may be an update for the stream. The Window updates for padding (if present) may appear at any time. The
+ * comments in the code below are only indicative of what the frames are likely to contain. Actual frame order
+ * with padding may be different.
*/
// Connection window update after reading request body
@@ -577,8 +558,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- protected String getResponseBodyFrameTrace(int streamId, int status, String contentType,
- String contentLanguage, String body, String cl) {
+ protected String getResponseBodyFrameTrace(int streamId, int status, String contentType, String contentLanguage,
+ String body, String cl) {
StringBuilder result = new StringBuilder();
result.append(streamId);
result.append("-HeadersStart\n");
@@ -706,20 +687,16 @@ public abstract class Http2TestBase extends TomcatBaseTest {
doHttpUpgrade(DEFAULT_CONNECTION_HEADER_VALUE, "h2c", EMPTY_HTTP2_SETTINGS_HEADER, true);
}
- protected void doHttpUpgrade(String connection, String upgrade, String settings,
- boolean validate) throws IOException {
- byte[] upgradeRequest = ("GET /simple HTTP/1.1\r\n" +
- "Host: localhost:" + getPort() + "\r\n" +
- "Connection: "+ connection + "\r\n" +
- "Upgrade: " + upgrade + "\r\n" +
- settings +
- "\r\n").getBytes(StandardCharsets.ISO_8859_1);
+ protected void doHttpUpgrade(String connection, String upgrade, String settings, boolean validate)
+ throws IOException {
+ byte[] upgradeRequest = ("GET /simple HTTP/1.1\r\n" + "Host: localhost:" + getPort() + "\r\n" + "Connection: " +
+ connection + "\r\n" + "Upgrade: " + upgrade + "\r\n" + settings + "\r\n")
+ .getBytes(StandardCharsets.ISO_8859_1);
os.write(upgradeRequest);
os.flush();
if (validate) {
- Assert.assertTrue("Failed to read HTTP Upgrade response",
- readHttpUpgradeResponse());
+ Assert.assertTrue("Failed to read HTTP Upgrade response", readHttpUpgradeResponse());
}
}
@@ -767,24 +744,24 @@ public abstract class Http2TestBase extends TomcatBaseTest {
while (seen < 4) {
input.fill(true, singleByte);
switch (seen) {
- case 0:
- case 2: {
- if (singleByte[0] == '\r') {
- seen++;
- } else {
- seen = 0;
+ case 0:
+ case 2: {
+ if (singleByte[0] == '\r') {
+ seen++;
+ } else {
+ seen = 0;
+ }
+ break;
}
- break;
- }
- case 1:
- case 3: {
- if (singleByte[0] == '\n') {
- seen++;
- } else {
- seen = 0;
+ case 1:
+ case 3: {
+ if (singleByte[0] == '\n') {
+ seen++;
+ } else {
+ seen = 0;
+ }
+ break;
}
- break;
- }
}
data.put(singleByte[0]);
}
@@ -793,8 +770,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
throw new IOException("End of headers not found");
}
- String response = new String(data.array(), data.arrayOffset(),
- data.arrayOffset() + data.position(), StandardCharsets.ISO_8859_1);
+ String response = new String(data.array(), data.arrayOffset(), data.arrayOffset() + data.position(),
+ StandardCharsets.ISO_8859_1);
return response.split("\r\n");
}
@@ -1022,13 +999,12 @@ public abstract class Http2TestBase extends TomcatBaseTest {
}
- void handleGoAwayResponse(int lastStream, Http2Error expectedError)
- throws Http2Exception, IOException {
+ void handleGoAwayResponse(int lastStream, Http2Error expectedError) throws Http2Exception, IOException {
try {
parser.readFrame();
- Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
- "0-Goaway-[" + lastStream + "]-[" + expectedError.getCode() + "]-["));
+ Assert.assertTrue(output.getTrace(),
+ output.getTrace().startsWith("0-Goaway-[" + lastStream + "]-[" + expectedError.getCode() + "]-["));
} catch (SocketException se) {
// On some platform / Connector combinations (e.g. Windows / NIO2),
// the TCP connection close will be processed before the client gets
@@ -1039,8 +1015,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
Assume.assumeTrue("This test is only expected to trigger an exception with NIO2",
connector.getProtocolHandlerClassName().contains("Nio2"));
- Assume.assumeTrue("This test is only expected to trigger an exception on Windows",
- JrePlatform.IS_WINDOWS);
+ Assume.assumeTrue("This test is only expected to trigger an exception on Windows", JrePlatform.IS_WINDOWS);
}
}
@@ -1222,7 +1197,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
trace.append("0-Settings-Ack\n");
} else {
trace.append("0-Settings-End\n");
- sendSettings(0, true);
+ sendSettings(0, true);
}
}
@@ -1263,7 +1238,8 @@ public abstract class Http2TestBase extends TomcatBaseTest {
@Override
public void priorityUpdate(int prioritizedStreamID, Priority p) throws Http2Exception {
- trace.append(prioritizedStreamID + "-PriorityUpdate-[" + p.getUrgency()+ "]-[" + p.getIncremental()+ "]\n");
+ trace.append(
+ prioritizedStreamID + "-PriorityUpdate-[" + p.getUrgency() + "]-[" + p.getIncremental() + "]\n");
}
@@ -1329,8 +1305,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// Generate an empty response
resp.setContentType("application/octet-stream");
resp.setContentLength(0);
@@ -1344,8 +1319,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
}
@@ -1358,8 +1332,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
public static final int CONTENT_LENGTH = 8192;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// Generate content with a simple known format.
resp.setContentType("application/octet-stream");
@@ -1378,8 +1351,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
@Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// Do not do this at home. The unconstrained buffer is a DoS risk.
// Have to read into a buffer because clients typically do not start
@@ -1404,8 +1376,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// Generate content with a simple known format that will exceed the
// default flow control window for a stream.
resp.setContentType("application/octet-stream");
@@ -1430,8 +1401,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/plain");
resp.setCharacterEncoding("UTF-8");
resp.getWriter().print("Cookie count: " + req.getCookies().length);
@@ -1445,8 +1415,7 @@ public abstract class Http2TestBase extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/plain");
resp.setCharacterEncoding("UTF-8");
StringBuilder headerValue = new StringBuilder();
@@ -1465,10 +1434,9 @@ public abstract class Http2TestBase extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
@Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- Map<String,String[]> params = req.getParameterMap();
+ Map<String, String[]> params = req.getParameterMap();
resp.setContentType("text/plain");
resp.setCharacterEncoding("UTF-8");
@@ -1483,15 +1451,13 @@ public abstract class Http2TestBase extends TomcatBaseTest {
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// Request bodies are unusual with GET but not illegal
doPost(req, resp);
}
@Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
long total = 0;
long read = 0;
diff --git a/test/org/apache/coyote/http2/TestAsync.java b/test/org/apache/coyote/http2/TestAsync.java
index 1d497bf09b..43a2506a62 100644
--- a/test/org/apache/coyote/http2/TestAsync.java
+++ b/test/org/apache/coyote/http2/TestAsync.java
@@ -68,11 +68,9 @@ public class TestAsync extends Http2TestBase {
for (Boolean streamUnlimited : booleans) {
for (Boolean useNonContainerThreadForWrite : booleans) {
for (Boolean largeInitialWindow : booleans) {
- parameterSets.add(new Object[] {
- base[0], base[1],
- expandConnectionFirst, connectionUnlimited, streamUnlimited,
- useNonContainerThreadForWrite, largeInitialWindow
- });
+ parameterSets.add(
+ new Object[] { base[0], base[1], expandConnectionFirst, connectionUnlimited,
+ streamUnlimited, useNonContainerThreadForWrite, largeInitialWindow });
}
}
}
@@ -110,8 +108,7 @@ public class TestAsync extends Http2TestBase {
Context ctxt = tomcat.addContext("", null);
Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
ctxt.addServletMappingDecoded("/simple", "simple");
- Wrapper w = Tomcat.addServlet(ctxt, "async",
- new AsyncServlet(blockCount, useNonContainerThreadForWrite));
+ Wrapper w = Tomcat.addServlet(ctxt, "async", new AsyncServlet(blockCount, useNonContainerThreadForWrite));
w.setAsyncSupported(true);
ctxt.addServletMappingDecoded("/async", "async");
tomcat.start();
@@ -128,8 +125,7 @@ public class TestAsync extends Http2TestBase {
if (largeInitialWindow) {
startingWindowSize = ((1 << 17) - 1);
- SettingValue sv =
- new SettingValue(Setting.INITIAL_WINDOW_SIZE.getId(), startingWindowSize);
+ SettingValue sv = new SettingValue(Setting.INITIAL_WINDOW_SIZE.getId(), startingWindowSize);
sendSettings(0, false, sv);
// Test code assumes connection window and stream window size are the same at the start
sendWindowUpdate(0, startingWindowSize - ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE);
@@ -217,8 +213,7 @@ public class TestAsync extends Http2TestBase {
* Not thread-safe. OK for this test. NOt OK for use in the real world.
*/
@Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
final AsyncContext asyncContext = request.startAsync();
@@ -259,7 +254,7 @@ public class TestAsync extends Http2TestBase {
while (output.isReady()) {
blockCount.incrementAndGet();
output.write(bytes);
- if (blockCount.get() == blockLimit) {
+ if (blockCount.get() == blockLimit) {
asyncContext.complete();
scheduler.shutdown();
return;
diff --git a/test/org/apache/coyote/http2/TestAsyncFlush.java b/test/org/apache/coyote/http2/TestAsyncFlush.java
index 4c548e4926..26db69beba 100644
--- a/test/org/apache/coyote/http2/TestAsyncFlush.java
+++ b/test/org/apache/coyote/http2/TestAsyncFlush.java
@@ -88,7 +88,7 @@ public class TestAsyncFlush extends Http2TestBase {
parser.readFrame();
// Body
- while (output.getBytesRead() < targetSize ) {
+ while (output.getBytesRead() < targetSize) {
if (output.getBytesRead() == totalWindow) {
sendWindowUpdate(3, ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE);
sendWindowUpdate(0, ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE);
@@ -113,8 +113,7 @@ public class TestAsyncFlush extends Http2TestBase {
}
@Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
final AsyncContext asyncContext = request.startAsync();
diff --git a/test/org/apache/coyote/http2/TestAsyncTimeout.java b/test/org/apache/coyote/http2/TestAsyncTimeout.java
index 8066840924..191a00b1e5 100644
--- a/test/org/apache/coyote/http2/TestAsyncTimeout.java
+++ b/test/org/apache/coyote/http2/TestAsyncTimeout.java
@@ -102,8 +102,7 @@ public class TestAsyncTimeout extends Http2TestBase {
}
@Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws IOException {
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
// The idea of this test is that the timeout kicks in after 2
// seconds and stops the async thread early rather than letting it
diff --git a/test/org/apache/coyote/http2/TestCancelledUpload.java b/test/org/apache/coyote/http2/TestCancelledUpload.java
index 2407f1f512..fbe1725c04 100644
--- a/test/org/apache/coyote/http2/TestCancelledUpload.java
+++ b/test/org/apache/coyote/http2/TestCancelledUpload.java
@@ -42,7 +42,8 @@ public class TestCancelledUpload extends Http2TestBase {
LogManager.getLogManager().getLogger("org.apache.coyote.http2").setLevel(Level.ALL);
try {
- ((AbstractHttp11Protocol<?>) http2Protocol.getHttp11Protocol()).setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
+ ((AbstractHttp11Protocol<?>) http2Protocol.getHttp11Protocol())
+ .setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
int bodySize = 8192;
int bodyCount = 20;
@@ -54,8 +55,8 @@ public class TestCancelledUpload extends Http2TestBase {
byte[] trailerFrameHeader = new byte[9];
ByteBuffer trailerPayload = ByteBuffer.allocate(256);
- buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload,
- null, trailerFrameHeader, trailerPayload, 3);
+ buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload, null,
+ trailerFrameHeader, trailerPayload, 3);
// Write the headers
writeFrame(headersFrameHeader, headersPayload);
@@ -71,7 +72,7 @@ public class TestCancelledUpload extends Http2TestBase {
// incoming frames.
// The request processing thread will:
// - read up to 128 bytes of request body
- // (and issue a window update for bytes read)
+ // (and issue a window update for bytes read)
// - write a 403 response with no response body
// The connection processing thread will:
// - read the request body until the flow control window is exhausted
@@ -84,12 +85,8 @@ public class TestCancelledUpload extends Http2TestBase {
}
// Not window update, not reset, must be the headers
- Assert.assertEquals("3-HeadersStart\n" +
- "3-Header-[:status]-[403]\n" +
- "3-Header-[content-length]-[0]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n",
- output.getTrace());
+ Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[403]\n" + "3-Header-[content-length]-[0]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n", output.getTrace());
output.clearTrace();
parser.readFrame();
@@ -99,9 +96,7 @@ public class TestCancelledUpload extends Http2TestBase {
}
// Not window update, not reset, must be the response body
- Assert.assertEquals("3-Body-0\n" +
- "3-EndOfStream\n",
- output.getTrace());
+ Assert.assertEquals("3-Body-0\n" + "3-EndOfStream\n", output.getTrace());
output.clearTrace();
parser.readFrame();
@@ -117,11 +112,9 @@ public class TestCancelledUpload extends Http2TestBase {
/*
* Looking for a RST frame with error type 3 (flow control error).
*
- * If there is a flow control window update for stream 0 it may be followed
- * by one for stream 3.
+ * If there is a flow control window update for stream 0 it may be followed by one for stream 3.
*
- * If there is a flow control window update for stream 3 it will always be
- * preceded by one for stream 0.
+ * If there is a flow control window update for stream 3 it will always be preceded by one for stream 0.
*/
private boolean checkReset() throws IOException, Http2Exception {
int lastConnectionFlowControlWindowUpdate = -1;
diff --git a/test/org/apache/coyote/http2/TestFlowControl.java b/test/org/apache/coyote/http2/TestFlowControl.java
index 8d45ce86d7..2450ffb781 100644
--- a/test/org/apache/coyote/http2/TestFlowControl.java
+++ b/test/org/apache/coyote/http2/TestFlowControl.java
@@ -99,17 +99,11 @@ public class TestFlowControl extends Http2TestBase {
// Language will depend on locale
String language = sm.getLocale().toLanguageTag();
- Assert.assertEquals(
- "3-HeadersStart\n" +
- "3-Header-[:status]-[404]\n" +
- "3-Header-[content-type]-[text/html;charset=utf-8]\n" +
- "3-Header-[content-language]-[" + language + "]\n" +
- "3-Header-[content-length]-[" + contentLength + "]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-" + contentLength + "\n" +
- "3-EndOfStream\n" +
- "3-RST-[0]\n", output.getTrace());
+ Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[404]\n" +
+ "3-Header-[content-type]-[text/html;charset=utf-8]\n" + "3-Header-[content-language]-[" + language +
+ "]\n" + "3-Header-[content-length]-[" + contentLength + "]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n" + "3-Body-" + contentLength +
+ "\n" + "3-EndOfStream\n" + "3-RST-[0]\n", output.getTrace());
output.clearTrace();
// Write 3*16k=48k of request body
@@ -132,8 +126,8 @@ public class TestFlowControl extends Http2TestBase {
/*
- * This might be unnecessary but given the potential for timing differences
- * across different systems a more robust approach seems prudent.
+ * This might be unnecessary but given the potential for timing differences across different systems a more robust
+ * approach seems prudent.
*/
private void waitForWindowSize(int streamId) throws Http2Exception, IOException {
String prefix = streamId + "-WindowSize-";
diff --git a/test/org/apache/coyote/http2/TestHpack.java b/test/org/apache/coyote/http2/TestHpack.java
index 991855417a..0d88ed112c 100644
--- a/test/org/apache/coyote/http2/TestHpack.java
+++ b/test/org/apache/coyote/http2/TestHpack.java
@@ -72,17 +72,21 @@ public class TestHpack {
private static class HeadersListener implements HpackDecoder.HeaderEmitter {
private final MimeHeaders headers;
+
HeadersListener(MimeHeaders headers) {
this.headers = headers;
}
+
@Override
public void emitHeader(String name, String value) {
headers.setValue(name).setString(value);
}
+
@Override
public void setHeaderException(StreamException streamException) {
// NO-OP
}
+
@Override
public void validateHeaders() throws StreamException {
// NO-OP
@@ -100,7 +104,7 @@ public class TestHpack {
// Skip the control characters except VTAB
if (i == 9 || i > 31 && i < 127 || i > 127) {
try {
- doTestHeaderValueBug60451("foo" + Character.toString((char) i) + "bar");
+ doTestHeaderValueBug60451("foo" + Character.toString((char) i) + "bar");
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage() + "[" + i + "]");
@@ -109,7 +113,7 @@ public class TestHpack {
}
}
- @Test(expected=HpackException.class)
+ @Test(expected = HpackException.class)
public void testExcessiveStringLiteralPadding() throws Exception {
MimeHeaders headers = new MimeHeaders();
headers.setValue("X-test").setString("foobar");
diff --git a/test/org/apache/coyote/http2/TestHttp2InitialConnection.java b/test/org/apache/coyote/http2/TestHttp2InitialConnection.java
index c11e954121..af62757ee9 100644
--- a/test/org/apache/coyote/http2/TestHttp2InitialConnection.java
+++ b/test/org/apache/coyote/http2/TestHttp2InitialConnection.java
@@ -67,8 +67,8 @@ public class TestHttp2InitialConnection extends Http2TestBase {
@Override
- protected void doHttpUpgrade(String connection, String upgrade, String settings,
- boolean validate) throws IOException {
+ protected void doHttpUpgrade(String connection, String upgrade, String settings, boolean validate)
+ throws IOException {
StringBuilder request = new StringBuilder();
request.append("GET /simple HTTP/1.1\r\n");
for (String hostHeader : testData.getHostHeaders()) {
@@ -98,8 +98,7 @@ public class TestHttp2InitialConnection extends Http2TestBase {
os.flush();
if (validate) {
- Assert.assertTrue("Failed to read HTTP Upgrade response",
- readHttpUpgradeResponse());
+ Assert.assertTrue("Failed to read HTTP Upgrade response", readHttpUpgradeResponse());
}
}
@@ -110,42 +109,33 @@ public class TestHttp2InitialConnection extends Http2TestBase {
return super.getResponseBodyFrameTrace(streamId, body);
} else if (testData.getExpectedStatus() == 400) {
/*
- * Need to be careful here. The test wants the exact content length
- * in bytes.
- * This will vary depending on where the test is run due to:
- * - The length of the version string that appears once in the error
- * page
- * - The status header uses a UTF-8 EN dash. When running in an IDE
- * the UTF-8 properties files will be used directly rather than
- * after native2ascii conversion.
+ * Need to be careful here. The test wants the exact content length in bytes. This will vary depending on
+ * where the test is run due to: - The length of the version string that appears once in the error page -
+ * The status header uses a UTF-8 EN dash. When running in an IDE the UTF-8 properties files will be used
+ * directly rather than after native2ascii conversion.
*
* Note: The status header appears twice in the error page.
*/
int serverInfoLength = ServerInfo.getServerInfo().getBytes().length;
- StringManager sm = StringManager.getManager(
- ErrorReportValve.class.getPackage().getName(), Locale.ENGLISH);
+ StringManager sm = StringManager.getManager(ErrorReportValve.class.getPackage().getName(), Locale.ENGLISH);
String reason = sm.getString("http." + testData.getExpectedStatus() + ".reason");
int descriptionLength = sm.getString("http." + testData.getExpectedStatus() + ".desc")
.getBytes(StandardCharsets.UTF_8).length;
int statusHeaderLength = sm
- .getString("errorReportValve.statusHeader",
- String.valueOf(testData.getExpectedStatus()), reason)
- .getBytes(StandardCharsets.UTF_8).length;
- int typeLabelLength = sm.getString("errorReportValve.type")
+ .getString("errorReportValve.statusHeader", String.valueOf(testData.getExpectedStatus()), reason)
.getBytes(StandardCharsets.UTF_8).length;
+ int typeLabelLength = sm.getString("errorReportValve.type").getBytes(StandardCharsets.UTF_8).length;
int statusReportLabelLength = sm.getString("errorReportValve.statusReport")
.getBytes(StandardCharsets.UTF_8).length;
int descriptionLabelLength = sm.getString("errorReportValve.description")
.getBytes(StandardCharsets.UTF_8).length;
// 196 bytes is the static length of the pure HTML code from the ErrorReportValve
- int len = 196 + org.apache.catalina.util.TomcatCSS.TOMCAT_CSS
- .getBytes(StandardCharsets.UTF_8).length +
- typeLabelLength + statusReportLabelLength + descriptionLabelLength +
- descriptionLength + serverInfoLength + statusHeaderLength * 2;
+ int len = 196 + org.apache.catalina.util.TomcatCSS.TOMCAT_CSS.getBytes(StandardCharsets.UTF_8).length +
+ typeLabelLength + statusReportLabelLength + descriptionLabelLength + descriptionLength +
+ serverInfoLength + statusHeaderLength * 2;
String contentLength = String.valueOf(len);
- return getResponseBodyFrameTrace(streamId,
- testData.getExpectedStatus(), "text/html;charset=utf-8",
- "en", contentLength, contentLength);
+ return getResponseBodyFrameTrace(streamId, testData.getExpectedStatus(), "text/html;charset=utf-8", "en",
+ contentLength, contentLength);
} else {
Assert.fail();
// To keep the IDE happy
diff --git a/test/org/apache/coyote/http2/TestHttp2Limits.java b/test/org/apache/coyote/http2/TestHttp2Limits.java
index 1bf08bc1aa..b3214eb012 100644
--- a/test/org/apache/coyote/http2/TestHttp2Limits.java
+++ b/test/org/apache/coyote/http2/TestHttp2Limits.java
@@ -43,8 +43,7 @@ public class TestHttp2Limits extends Http2TestBase {
@Test
public void testSettingsOverheadLimits() throws Exception {
http2Connect();
- String errMsg = sm.getString("upgradeHandler.tooMuchOverhead", "\\p{XDigit}++")
- .replace("[", "\\[");
+ String errMsg = sm.getString("upgradeHandler.tooMuchOverhead", "\\p{XDigit}++").replace("[", "\\[");
String overHeadMsgRegx = "0-Goaway-\\[1]-\\[11]-\\[" + errMsg + "]";
for (int i = 0; i < 100; i++) {
@@ -100,8 +99,7 @@ public class TestHttp2Limits extends Http2TestBase {
@Test
public void testHeaderLimits20x32WithLimit10() throws Exception {
// Check lower count limit is enforced
- doTestHeaderLimits(20, 32, -1, 10, Constants.DEFAULT_MAX_HEADER_SIZE, 0,
- FailureMode.STREAM_RESET);
+ doTestHeaderLimits(20, 32, -1, 10, Constants.DEFAULT_MAX_HEADER_SIZE, 0, FailureMode.STREAM_RESET);
}
@@ -123,29 +121,28 @@ public class TestHttp2Limits extends Http2TestBase {
@Test
public void testHeaderLimits3x1024WithLimit2048() throws Exception {
// Check lower size limit is enforced
- doTestHeaderLimits(3, 1024, -1, Constants.DEFAULT_MAX_HEADER_COUNT, 2 * 1024, 0,
- FailureMode.STREAM_RESET);
+ doTestHeaderLimits(3, 1024, -1, Constants.DEFAULT_MAX_HEADER_COUNT, 2 * 1024, 0, FailureMode.STREAM_RESET);
}
@Test
public void testHeaderLimits1x12k() throws Exception {
// Bug 60232
- doTestHeaderLimits(1, 12*1024, FailureMode.STREAM_RESET);
+ doTestHeaderLimits(1, 12 * 1024, FailureMode.STREAM_RESET);
}
@Test
public void testHeaderLimits1x12kin1kChunks() throws Exception {
// Bug 60232
- doTestHeaderLimits(1, 12*1024, 1024, FailureMode.STREAM_RESET);
+ doTestHeaderLimits(1, 12 * 1024, 1024, FailureMode.STREAM_RESET);
}
@Test
public void testHeaderLimits1x12kin1kChunksThenNewRequest() throws Exception {
// Bug 60232
- doTestHeaderLimits(1, 12*1024, 1024, FailureMode.STREAM_RESET);
+ doTestHeaderLimits(1, 12 * 1024, 1024, FailureMode.STREAM_RESET);
output.clearTrace();
sendSimpleGetRequest(5);
@@ -158,7 +155,7 @@ public class TestHttp2Limits extends Http2TestBase {
@Test
public void testHeaderLimits1x32k() throws Exception {
// Bug 60232
- doTestHeaderLimits(1, 32*1024, FailureMode.CONNECTION_RESET);
+ doTestHeaderLimits(1, 32 * 1024, FailureMode.CONNECTION_RESET);
}
@@ -168,54 +165,51 @@ public class TestHttp2Limits extends Http2TestBase {
// 500ms per frame write delay to give server a chance to process the
// stream reset and the connection reset before the request is fully
// sent.
- doTestHeaderLimits(1, 32*1024, 1024, 500, FailureMode.CONNECTION_RESET);
+ doTestHeaderLimits(1, 32 * 1024, 1024, 500, FailureMode.CONNECTION_RESET);
}
@Test
public void testHeaderLimits1x128k() throws Exception {
// Bug 60232
- doTestHeaderLimits(1, 128*1024, FailureMode.CONNECTION_RESET);
+ doTestHeaderLimits(1, 128 * 1024, FailureMode.CONNECTION_RESET);
}
@Test
public void testHeaderLimits1x512k() throws Exception {
// Bug 60232
- doTestHeaderLimits(1, 512*1024, FailureMode.CONNECTION_RESET);
+ doTestHeaderLimits(1, 512 * 1024, FailureMode.CONNECTION_RESET);
}
@Test
public void testHeaderLimits10x512k() throws Exception {
// Bug 60232
- doTestHeaderLimits(10, 512*1024, FailureMode.CONNECTION_RESET);
+ doTestHeaderLimits(10, 512 * 1024, FailureMode.CONNECTION_RESET);
}
- private void doTestHeaderLimits(int headerCount, int headerSize, FailureMode failMode)
- throws Exception {
+ private void doTestHeaderLimits(int headerCount, int headerSize, FailureMode failMode) throws Exception {
doTestHeaderLimits(headerCount, headerSize, -1, failMode);
}
- private void doTestHeaderLimits(int headerCount, int headerSize, int maxHeaderPayloadSize,
- FailureMode failMode) throws Exception {
+ private void doTestHeaderLimits(int headerCount, int headerSize, int maxHeaderPayloadSize, FailureMode failMode)
+ throws Exception {
doTestHeaderLimits(headerCount, headerSize, maxHeaderPayloadSize, 0, failMode);
}
- private void doTestHeaderLimits(int headerCount, int headerSize, int maxHeaderPayloadSize,
- int delayms, FailureMode failMode) throws Exception {
- doTestHeaderLimits(headerCount, headerSize, maxHeaderPayloadSize,
- Constants.DEFAULT_MAX_HEADER_COUNT, Constants.DEFAULT_MAX_HEADER_SIZE, delayms,
- failMode);
+ private void doTestHeaderLimits(int headerCount, int headerSize, int maxHeaderPayloadSize, int delayms,
+ FailureMode failMode) throws Exception {
+ doTestHeaderLimits(headerCount, headerSize, maxHeaderPayloadSize, Constants.DEFAULT_MAX_HEADER_COUNT,
+ Constants.DEFAULT_MAX_HEADER_SIZE, delayms, failMode);
}
- private void doTestHeaderLimits(int headerCount, int headerSize, int maxHeaderPayloadSize,
- int maxHeaderCount, int maxHeaderSize, int delayms, FailureMode failMode)
- throws Exception {
+ private void doTestHeaderLimits(int headerCount, int headerSize, int maxHeaderPayloadSize, int maxHeaderCount,
+ int maxHeaderSize, int delayms, FailureMode failMode) throws Exception {
// Build the custom headers
List<String[]> customHeaders = new ArrayList<>();
@@ -228,7 +222,7 @@ public class TestHttp2Limits extends Http2TestBase {
}
String v = headerValue.toString();
for (int i = 0; i < headerCount; i++) {
- customHeaders.add(new String[] {"X-TomcatTest" + i, v});
+ customHeaders.add(new String[] { "X-TomcatTest" + i, v });
}
enableHttp2();
@@ -250,8 +244,8 @@ public class TestHttp2Limits extends Http2TestBase {
byte[] frameHeader = new byte[9];
// Assumes at least one custom header and that all headers are the same
// length. These assumptions are valid for these tests.
- ByteBuffer headersPayload = ByteBuffer.allocate(200 + (int) (customHeaders.size() *
- customHeaders.iterator().next()[1].length() * 1.2));
+ ByteBuffer headersPayload = ByteBuffer
+ .allocate(200 + (int) (customHeaders.size() * customHeaders.iterator().next()[1].length() * 1.2));
populateHeadersPayload(headersPayload, customHeaders, "/simple");
@@ -262,8 +256,7 @@ public class TestHttp2Limits extends Http2TestBase {
while (left > 0) {
int thisTime = Math.min(left, maxHeaderPayloadSize);
populateFrameHeader(frameHeader, written, left, thisTime, 3);
- writeFrame(frameHeader, headersPayload, headersPayload.limit() - left,
- thisTime, delayms);
+ writeFrame(frameHeader, headersPayload, headersPayload.limit() - left, thisTime, delayms);
left -= thisTime;
written += thisTime;
}
@@ -272,49 +265,49 @@ public class TestHttp2Limits extends Http2TestBase {
}
switch (failMode) {
- case NONE: {
- // Expect a normal response
- readSimpleGetResponse();
- Assert.assertEquals(getSimpleResponseTrace(3), output.getTrace());
- Assert.assertNull(e);
- break;
- }
- case STREAM_RESET: {
- // Expect a stream reset
- parser.readFrame();
- Assert.assertEquals("3-RST-[11]\n", output.getTrace());
- Assert.assertNull(e);
- break;
- }
- case CONNECTION_RESET: {
- // This message uses i18n and needs to be used in a regular
- // expression (since we don't know the connection ID). Generate the
- // string as a regular expression and then replace '[' and ']' with
- // the escaped values.
- String limitMessage = sm.getString("http2Parser.headerLimitSize", "\\p{XDigit}++", "3");
- limitMessage = limitMessage.replace("[", "\\[").replace("]", "\\]");
- // Connection reset. Connection ID will vary so use a pattern
- // On some platform / Connector combinations the TCP connection close
- // will be processed before the client gets a chance to read the
- // connection close frame which will trigger an
- // IOException when we try to read the frame.
- // Note: Some platforms will allow the read if if the write fails
- // above.
- try {
+ case NONE: {
+ // Expect a normal response
+ readSimpleGetResponse();
+ Assert.assertEquals(getSimpleResponseTrace(3), output.getTrace());
+ Assert.assertNull(e);
+ break;
+ }
+ case STREAM_RESET: {
+ // Expect a stream reset
parser.readFrame();
- MatcherAssert.assertThat(output.getTrace(), RegexMatcher.matchesRegex(
- "0-Goaway-\\[1\\]-\\[11\\]-\\[" + limitMessage + "\\]"));
- } catch (IOException se) {
- // Expected on some platforms
+ Assert.assertEquals("3-RST-[11]\n", output.getTrace());
+ Assert.assertNull(e);
+ break;
+ }
+ case CONNECTION_RESET: {
+ // This message uses i18n and needs to be used in a regular
+ // expression (since we don't know the connection ID). Generate the
+ // string as a regular expression and then replace '[' and ']' with
+ // the escaped values.
+ String limitMessage = sm.getString("http2Parser.headerLimitSize", "\\p{XDigit}++", "3");
+ limitMessage = limitMessage.replace("[", "\\[").replace("]", "\\]");
+ // Connection reset. Connection ID will vary so use a pattern
+ // On some platform / Connector combinations the TCP connection close
+ // will be processed before the client gets a chance to read the
+ // connection close frame which will trigger an
+ // IOException when we try to read the frame.
+ // Note: Some platforms will allow the read if if the write fails
+ // above.
+ try {
+ parser.readFrame();
+ MatcherAssert.assertThat(output.getTrace(),
+ RegexMatcher.matchesRegex("0-Goaway-\\[1\\]-\\[11\\]-\\[" + limitMessage + "\\]"));
+ } catch (IOException se) {
+ // Expected on some platforms
+ }
+ break;
}
- break;
- }
}
}
- private void populateHeadersPayload(ByteBuffer headersPayload, List<String[]> customHeaders,
- String path) throws Exception {
+ private void populateHeadersPayload(ByteBuffer headersPayload, List<String[]> customHeaders, String path)
+ throws Exception {
MimeHeaders headers = new MimeHeaders();
headers.addValue(":method").setString("GET");
headers.addValue(":scheme").setString("http");
@@ -333,8 +326,8 @@ public class TestHttp2Limits extends Http2TestBase {
}
- private void populateFrameHeader(byte[] frameHeader, int written, int left, int thisTime,
- int streamId) throws Exception {
+ private void populateFrameHeader(byte[] frameHeader, int written, int left, int thisTime, int streamId)
+ throws Exception {
ByteUtil.setThreeBytes(frameHeader, 0, thisTime);
if (written == 0) {
frameHeader[3] = FrameType.HEADERS.getIdByte();
@@ -394,8 +387,7 @@ public class TestHttp2Limits extends Http2TestBase {
}
- private void doTestCookieLimit(int cookieCount, int maxCookieCount, int failMode)
- throws Exception {
+ private void doTestCookieLimit(int cookieCount, int maxCookieCount, int failMode) throws Exception {
enableHttp2();
@@ -415,7 +407,7 @@ public class TestHttp2Limits extends Http2TestBase {
List<String[]> customHeaders = new ArrayList<>();
for (int i = 0; i < cookieCount; i++) {
- customHeaders.add(new String[] {"Cookie", "a" + cookieCount + "=b" + cookieCount});
+ customHeaders.add(new String[] { "Cookie", "a" + cookieCount + "=b" + cookieCount });
}
populateHeadersPayload(headersPayload, customHeaders, "/cookie");
@@ -424,55 +416,53 @@ public class TestHttp2Limits extends Http2TestBase {
writeFrame(frameHeader, headersPayload);
switch (failMode) {
- case 0: {
- parser.readFrame();
- parser.readFrame();
- parser.readFrame();
- System.out.println(output.getTrace());
- Assert.assertEquals(getCookieResponseTrace(3, cookieCount), output.getTrace());
- break;
- }
- case 1: {
- // Check status is 400
- parser.readFrame();
- Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
- "3-HeadersStart\n3-Header-[:status]-[400]"));
- output.clearTrace();
- // Check EOS followed by error page body
- parser.readFrame();
- Assert.assertTrue(output.getTrace(), output.getTrace().startsWith("3-EndOfStream\n3-Body-<!doctype"));
- break;
- }
- default: {
- Assert.fail("Unknown failure mode specified");
- }
+ case 0: {
+ parser.readFrame();
+ parser.readFrame();
+ parser.readFrame();
+ System.out.println(output.getTrace());
+ Assert.assertEquals(getCookieResponseTrace(3, cookieCount), output.getTrace());
+ break;
+ }
+ case 1: {
+ // Check status is 400
+ parser.readFrame();
+ Assert.assertTrue(output.getTrace(),
+ output.getTrace().startsWith("3-HeadersStart\n3-Header-[:status]-[400]"));
+ output.clearTrace();
+ // Check EOS followed by error page body
+ parser.readFrame();
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith("3-EndOfStream\n3-Body-<!doctype"));
+ break;
+ }
+ default: {
+ Assert.fail("Unknown failure mode specified");
+ }
}
}
@Test
- public void testPostWithTrailerHeadersDefaultLimit() throws Exception{
- doTestPostWithTrailerHeaders(Constants.DEFAULT_MAX_TRAILER_COUNT,
- Constants.DEFAULT_MAX_TRAILER_SIZE, FailureMode.NONE);
+ public void testPostWithTrailerHeadersDefaultLimit() throws Exception {
+ doTestPostWithTrailerHeaders(Constants.DEFAULT_MAX_TRAILER_COUNT, Constants.DEFAULT_MAX_TRAILER_SIZE,
+ FailureMode.NONE);
}
@Test
- public void testPostWithTrailerHeadersCount0() throws Exception{
- doTestPostWithTrailerHeaders(0, Constants.DEFAULT_MAX_TRAILER_SIZE,
- FailureMode.STREAM_RESET);
+ public void testPostWithTrailerHeadersCount0() throws Exception {
+ doTestPostWithTrailerHeaders(0, Constants.DEFAULT_MAX_TRAILER_SIZE, FailureMode.STREAM_RESET);
}
@Test
- public void testPostWithTrailerHeadersSize0() throws Exception{
- doTestPostWithTrailerHeaders(Constants.DEFAULT_MAX_TRAILER_COUNT, 0,
- FailureMode.CONNECTION_RESET);
+ public void testPostWithTrailerHeadersSize0() throws Exception {
+ doTestPostWithTrailerHeaders(Constants.DEFAULT_MAX_TRAILER_COUNT, 0, FailureMode.CONNECTION_RESET);
}
- private void doTestPostWithTrailerHeaders(int maxTrailerCount, int maxTrailerSize,
- FailureMode failMode) throws Exception {
+ private void doTestPostWithTrailerHeaders(int maxTrailerCount, int maxTrailerSize, FailureMode failMode)
+ throws Exception {
enableHttp2();
((AbstractHttp11Protocol<?>) http2Protocol.getHttp11Protocol()).setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
@@ -494,8 +484,8 @@ public class TestHttp2Limits extends Http2TestBase {
byte[] trailerFrameHeader = new byte[9];
ByteBuffer trailerPayload = ByteBuffer.allocate(256);
- buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload,
- null, trailerFrameHeader, trailerPayload, 3);
+ buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload, null,
+ trailerFrameHeader, trailerPayload, 3);
// Write the headers
writeFrame(headersFrameHeader, headersPayload);
@@ -505,56 +495,48 @@ public class TestHttp2Limits extends Http2TestBase {
writeFrame(trailerFrameHeader, trailerPayload);
switch (failMode) {
- case NONE: {
- parser.readFrame();
- parser.readFrame();
- parser.readFrame();
- parser.readFrame();
-
- String len = Integer.toString(256 + TRAILER_HEADER_VALUE.length());
-
- Assert.assertEquals("0-WindowSize-[256]\n" +
- "3-WindowSize-[256]\n" +
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-length]-[" + len + "]\n" +
- "3-Header-[date]-["+ DEFAULT_DATE + "]\n" +
- "3-HeadersEnd\n" +
- "3-Body-" +
- len +
- "\n" +
- "3-EndOfStream\n",
- output.getTrace());
- break;
- }
- case STREAM_RESET: {
- // NIO2 can sometimes send window updates depending timing
- skipWindowSizeFrames();
-
- // Async I/O can sometimes result in a stream closed reset before
- // the enhance your calm reset
- if ("3-RST-[5]\n".equals(output.getTrace())) {
- output.clearTrace();
+ case NONE: {
+ parser.readFrame();
+ parser.readFrame();
+ parser.readFrame();
parser.readFrame();
- }
- Assert.assertEquals("3-RST-[11]\n", output.getTrace());
- break;
- }
- case CONNECTION_RESET: {
- // NIO2 can sometimes send window updates depending timing
- skipWindowSizeFrames();
-
- // This message uses i18n and needs to be used in a regular
- // expression (since we don't know the connection ID). Generate the
- // string as a regular expression and then replace '[' and ']' with
- // the escaped values.
- String limitMessage = sm.getString("http2Parser.headerLimitSize", "\\p{XDigit}++", "3");
- limitMessage = limitMessage.replace("[", "\\[").replace("]", "\\]");
- MatcherAssert.assertThat(output.getTrace(), RegexMatcher.matchesRegex(
- "0-Goaway-\\[3\\]-\\[11\\]-\\[" + limitMessage + "\\]"));
- break;
- }
+ String len = Integer.toString(256 + TRAILER_HEADER_VALUE.length());
+
+ Assert.assertEquals("0-WindowSize-[256]\n" + "3-WindowSize-[256]\n" + "3-HeadersStart\n" +
+ "3-Header-[:status]-[200]\n" + "3-Header-[content-length]-[" + len + "]\n" +
+ "3-Header-[date]-[" + DEFAULT_DATE + "]\n" + "3-HeadersEnd\n" + "3-Body-" + len + "\n" +
+ "3-EndOfStream\n", output.getTrace());
+ break;
+ }
+ case STREAM_RESET: {
+ // NIO2 can sometimes send window updates depending timing
+ skipWindowSizeFrames();
+
+ // Async I/O can sometimes result in a stream closed reset before
+ // the enhance your calm reset
+ if ("3-RST-[5]\n".equals(output.getTrace())) {
+ output.clearTrace();
+ parser.readFrame();
+ }
+
+ Assert.assertEquals("3-RST-[11]\n", output.getTrace());
+ break;
+ }
+ case CONNECTION_RESET: {
+ // NIO2 can sometimes send window updates depending timing
+ skipWindowSizeFrames();
+
+ // This message uses i18n and needs to be used in a regular
+ // expression (since we don't know the connection ID). Generate the
+ // string as a regular expression and then replace '[' and ']' with
+ // the escaped values.
+ String limitMessage = sm.getString("http2Parser.headerLimitSize", "\\p{XDigit}++", "3");
+ limitMessage = limitMessage.replace("[", "\\[").replace("]", "\\]");
+ MatcherAssert.assertThat(output.getTrace(),
+ RegexMatcher.matchesRegex("0-Goaway-\\[3\\]-\\[11\\]-\\[" + limitMessage + "\\]"));
+ break;
+ }
}
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_3_2.java b/test/org/apache/coyote/http2/TestHttp2Section_3_2.java
index 8f1057d6d5..be875ed9df 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_3_2.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_3_2.java
@@ -22,16 +22,13 @@ import java.nio.charset.StandardCharsets;
import org.junit.Test;
/**
- * Unit tests for Section 3.2 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 3.2 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_3_2 extends Http2TestBase {
// Note: Tests for zero/multiple HTTP2-Settings fields can be found below
- // in the tests for section 3.2.1
+ // in the tests for section 3.2.1
// TODO: Test initial requests with bodies of various sizes
@@ -54,7 +51,7 @@ public class TestHttp2Section_3_2 extends Http2TestBase {
}
- @Test(timeout=10000)
+ @Test(timeout = 10000)
public void testConnectionNoPreface() throws Exception {
setupAsFarAsUpgrade();
@@ -68,7 +65,7 @@ public class TestHttp2Section_3_2 extends Http2TestBase {
}
- @Test(timeout=10000)
+ @Test(timeout = 10000)
public void testConnectionIncompletePrefaceStart() throws Exception {
setupAsFarAsUpgrade();
@@ -85,14 +82,13 @@ public class TestHttp2Section_3_2 extends Http2TestBase {
}
- @Test(timeout=10000)
+ @Test(timeout = 10000)
public void testConnectionInvalidPrefaceStart() throws Exception {
setupAsFarAsUpgrade();
// If we send an incomplete preface the server should kill the
// connection.
- os.write("xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxxx".getBytes(
- StandardCharsets.ISO_8859_1));
+ os.write("xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxxx".getBytes(StandardCharsets.ISO_8859_1));
os.flush();
try {
// Make the parser read something.
@@ -104,7 +100,7 @@ public class TestHttp2Section_3_2 extends Http2TestBase {
@Test
- public void testConnectionUpgradeFirstResponse() throws Exception{
+ public void testConnectionUpgradeFirstResponse() throws Exception {
super.http2Connect();
}
@@ -117,7 +113,7 @@ public class TestHttp2Section_3_2 extends Http2TestBase {
}
- //------------------------------------------------------------ Section 3.2.1
+ // ------------------------------------------------------------ Section 3.2.1
@Test
public void testZeroHttp2Settings() throws Exception {
@@ -135,8 +131,7 @@ public class TestHttp2Section_3_2 extends Http2TestBase {
configureAndStartWebApplication();
openClientConnection();
doHttpUpgrade(Http2TestBase.DEFAULT_CONNECTION_HEADER_VALUE, "h2c",
- Http2TestBase.EMPTY_HTTP2_SETTINGS_HEADER +
- Http2TestBase.EMPTY_HTTP2_SETTINGS_HEADER, false);
+ Http2TestBase.EMPTY_HTTP2_SETTINGS_HEADER + Http2TestBase.EMPTY_HTTP2_SETTINGS_HEADER, false);
parseHttp11Response();
}
@@ -156,8 +151,7 @@ public class TestHttp2Section_3_2 extends Http2TestBase {
enableHttp2();
configureAndStartWebApplication();
openClientConnection();
- doHttpUpgrade("Upgrade\r\nConnection: HTTP2-Settings", "h2c",
- Http2TestBase.EMPTY_HTTP2_SETTINGS_HEADER, true);
+ doHttpUpgrade("Upgrade\r\nConnection: HTTP2-Settings", "h2c", Http2TestBase.EMPTY_HTTP2_SETTINGS_HEADER, true);
sendClientPreface();
validateHttp2InitialResponse();
}
@@ -168,8 +162,7 @@ public class TestHttp2Section_3_2 extends Http2TestBase {
enableHttp2();
configureAndStartWebApplication();
openClientConnection();
- doHttpUpgrade("HTTP2-Settings\r\nConnection: Upgrade", "h2c",
- Http2TestBase.EMPTY_HTTP2_SETTINGS_HEADER, true);
+ doHttpUpgrade("HTTP2-Settings\r\nConnection: Upgrade", "h2c", Http2TestBase.EMPTY_HTTP2_SETTINGS_HEADER, true);
sendClientPreface();
validateHttp2InitialResponse();
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_3_5.java b/test/org/apache/coyote/http2/TestHttp2Section_3_5.java
index 60112773b8..4f88571877 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_3_5.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_3_5.java
@@ -32,9 +32,7 @@ public class TestHttp2Section_3_5 extends Http2TestBase {
// Server settings
parser.readFrame();
- Assert.assertEquals("0-Settings-[3]-[200]\n" +
- "0-Settings-End\n"
- , output.getTrace());
+ Assert.assertEquals("0-Settings-[3]-[200]\n" + "0-Settings-End\n", output.getTrace());
output.clearTrace();
// Should send client preface here. This will trigger an error.
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_4_1.java b/test/org/apache/coyote/http2/TestHttp2Section_4_1.java
index 73a31d57a4..35872befac 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_4_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_4_1.java
@@ -22,16 +22,12 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 4.1 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 4.1 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_4_1 extends Http2TestBase {
- private static final byte[] UNKNOWN_FRAME = new byte[] {
- 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ private static final byte[] UNKNOWN_FRAME = new byte[] { 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00 };
// TODO: Tests for over-sized frames. Better located in tests for section 6?
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_4_2.java b/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
index 496825f38e..3c158c724d 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_4_2.java
@@ -20,11 +20,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 4.2 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 4.2 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_4_2 extends Http2TestBase {
@@ -77,7 +74,7 @@ public class TestHttp2Section_4_2 extends Http2TestBase {
os.write(ping);
- handleGoAwayResponse(1, Http2Error.FRAME_SIZE_ERROR);
+ handleGoAwayResponse(1, Http2Error.FRAME_SIZE_ERROR);
}
@@ -99,7 +96,7 @@ public class TestHttp2Section_4_2 extends Http2TestBase {
os.write(ping);
- handleGoAwayResponse(1, Http2Error.FRAME_SIZE_ERROR);
+ handleGoAwayResponse(1, Http2Error.FRAME_SIZE_ERROR);
}
@@ -125,7 +122,6 @@ public class TestHttp2Section_4_2 extends Http2TestBase {
// Read Stream reset frame
parser.readFrame();
- Assert.assertTrue(output.getTrace(),
- output.getTrace().startsWith("3-RST-[6]"));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith("3-RST-[6]"));
}
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_4_3.java b/test/org/apache/coyote/http2/TestHttp2Section_4_3.java
index dc65ee6395..772c26f2e7 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_4_3.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_4_3.java
@@ -22,11 +22,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 4.3 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 4.3 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_4_3 extends Http2TestBase {
@@ -46,7 +43,7 @@ public class TestHttp2Section_4_3 extends Http2TestBase {
// Process the request
writeFrame(frameHeader, headersPayload);
- handleGoAwayResponse(1, Http2Error.COMPRESSION_ERROR);
+ handleGoAwayResponse(1, Http2Error.COMPRESSION_ERROR);
}
@@ -87,6 +84,6 @@ public class TestHttp2Section_4_3 extends Http2TestBase {
sendPing();
- handleGoAwayResponse(1, Http2Error.COMPRESSION_ERROR);
+ handleGoAwayResponse(1, Http2Error.COMPRESSION_ERROR);
}
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_5_1.java b/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
index 62c507cdf7..cbe224ccfc 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_5_1.java
@@ -24,11 +24,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 5.§ of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 5.§ of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_5_1 extends Http2TestBase {
@@ -69,7 +66,7 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
// This should trigger a connection error
sendData(3, new byte[] {});
- handleGoAwayResponse(3, Http2Error.STREAM_CLOSED);
+ handleGoAwayResponse(3, Http2Error.STREAM_CLOSED);
}
@@ -108,7 +105,7 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
// Stream 1 is closed. This should trigger a connection error
sendData(1, new byte[] {});
- handleGoAwayResponse(1, Http2Error.STREAM_CLOSED);
+ handleGoAwayResponse(1, Http2Error.STREAM_CLOSED);
}
@@ -179,8 +176,10 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
// Allow second request to take up to 5 times first request or up to 1 second - whichever is the larger - mainly
// to allow for CI systems under load that can exhibit significant timing variation.
- Assert.assertTrue("First request took [" + durationFirst/1000000 + "ms], second request took [" +
- durationSecond/1000000 + "ms]", durationSecond < 1000000000 || durationSecond < durationFirst * 3);
+ Assert.assertTrue(
+ "First request took [" + durationFirst / 1000000 + "ms], second request took [" +
+ durationSecond / 1000000 + "ms]",
+ durationSecond < 1000000000 || durationSecond < durationFirst * 3);
// Should trigger an error since stream 3 should have been implicitly
// closed.
@@ -206,12 +205,8 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals("0-Settings-[3]-[1]\n" +
- "0-Settings-End\n" +
- "0-Settings-Ack\n" +
- "0-Ping-[0,0,0,0,0,0,0,1]\n" +
- getSimpleResponseTrace(1)
- , output.getTrace());
+ Assert.assertEquals("0-Settings-[3]-[1]\n" + "0-Settings-End\n" + "0-Settings-Ack\n" +
+ "0-Ping-[0,0,0,0,0,0,0,1]\n" + getSimpleResponseTrace(1), output.getTrace());
output.clearTrace();
sendLargeGetRequest(3);
@@ -231,8 +226,7 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
}
Assert.assertTrue(output.getTrace(),
- output.getTrace().contains("5-RST-[" +
- Http2Error.REFUSED_STREAM.getCode() + "]"));
+ output.getTrace().contains("5-RST-[" + Http2Error.REFUSED_STREAM.getCode() + "]"));
output.clearTrace();
// Connection window is zero.
@@ -273,12 +267,8 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals("0-Settings-[3]-[1]\n" +
- "0-Settings-End\n" +
- "0-Settings-Ack\n" +
- "0-Ping-[0,0,0,0,0,0,0,1]\n" +
- getSimpleResponseTrace(1)
- , output.getTrace());
+ Assert.assertEquals("0-Settings-[3]-[1]\n" + "0-Settings-End\n" + "0-Settings-Ack\n" +
+ "0-Ping-[0,0,0,0,0,0,0,1]\n" + getSimpleResponseTrace(1), output.getTrace());
output.clearTrace();
sendLargeGetRequest(3);
@@ -298,8 +288,7 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
}
Assert.assertTrue(output.getTrace(),
- output.getTrace().contains("5-RST-[" +
- Http2Error.REFUSED_STREAM.getCode() + "]"));
+ output.getTrace().contains("5-RST-[" + Http2Error.REFUSED_STREAM.getCode() + "]"));
output.clearTrace();
// Connection window is zero.
@@ -342,12 +331,8 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals("0-Settings-[3]-[1]\n" +
- "0-Settings-End\n" +
- "0-Settings-Ack\n" +
- "0-Ping-[0,0,0,0,0,0,0,1]\n" +
- getSimpleResponseTrace(1)
- , output.getTrace());
+ Assert.assertEquals("0-Settings-[3]-[1]\n" + "0-Settings-End\n" + "0-Settings-Ack\n" +
+ "0-Ping-[0,0,0,0,0,0,0,1]\n" + getSimpleResponseTrace(1), output.getTrace());
output.clearTrace();
sendLargeGetRequest(3);
@@ -401,12 +386,8 @@ public class TestHttp2Section_5_1 extends Http2TestBase {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals("0-Settings-[3]-[1]\n" +
- "0-Settings-End\n" +
- "0-Settings-Ack\n" +
- "0-Ping-[0,0,0,0,0,0,0,1]\n" +
- getSimpleResponseTrace(1)
- , output.getTrace());
+ Assert.assertEquals("0-Settings-[3]-[1]\n" + "0-Settings-End\n" + "0-Settings-Ack\n" +
+ "0-Ping-[0,0,0,0,0,0,0,1]\n" + getSimpleResponseTrace(1), output.getTrace());
output.clearTrace();
// Default connection window size is 64k-1.
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_5_2.java b/test/org/apache/coyote/http2/TestHttp2Section_5_2.java
index 35083face7..fbdd148de4 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_5_2.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_5_2.java
@@ -21,17 +21,14 @@ import org.junit.Before;
import org.junit.Test;
/**
- * Unit tests for Section 5.2 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 5.2 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_5_2 extends Http2TestBase {
/*
- * Get the connection to a point where 1k of 8k response body has been
- * read and the flow control for the stream has no capacity left.
+ * Get the connection to a point where 1k of 8k response body has been read and the flow control for the stream has
+ * no capacity left.
*/
@Override
@Before
@@ -80,7 +77,7 @@ public class TestHttp2Section_5_2 extends Http2TestBase {
@Test
public void testFlowControlLimits03() throws Exception {
- readBytes(8192,7168);
+ readBytes(8192, 7168);
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_5_5.java b/test/org/apache/coyote/http2/TestHttp2Section_5_5.java
index fb9966757a..c383a2e631 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_5_5.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_5_5.java
@@ -22,11 +22,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 5.5 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 5.5 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_5_5 extends Http2TestBase {
@@ -57,7 +54,7 @@ public class TestHttp2Section_5_5 extends Http2TestBase {
parser.readFrame();
- Assert.assertEquals("0-Settings-Ack\n", output.getTrace());
+ Assert.assertEquals("0-Settings-Ack\n", output.getTrace());
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_1.java b/test/org/apache/coyote/http2/TestHttp2Section_6_1.java
index 27a622380f..bd064ae152 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_1.java
@@ -23,11 +23,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 6.1 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 6.1 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_6_1 extends Http2TestBase {
@@ -41,15 +38,11 @@ public class TestHttp2Section_6_1 extends Http2TestBase {
sendSimplePostRequest(3, null);
readSimplePostResponse(false);
- Assert.assertEquals("0-WindowSize-[128]\n" +
- "3-WindowSize-[128]\n" +
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-length]-[128]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-128\n" +
- "3-EndOfStream\n", output.getTrace());
+ Assert.assertEquals(
+ "0-WindowSize-[128]\n" + "3-WindowSize-[128]\n" + "3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
+ "3-Header-[content-length]-[128]\n" + "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
+ "3-HeadersEnd\n" + "3-Body-128\n" + "3-EndOfStream\n",
+ output.getTrace());
}
@@ -79,19 +72,14 @@ public class TestHttp2Section_6_1 extends Http2TestBase {
trace = trace.replace(paddingWindowUpdate, "");
// The stream window update may or may not be present depending on
- // timing. Remove it if present.
+ // timing. Remove it if present.
if (trace.contains("3-WindowSize-[9]\n")) {
trace = trace.replace("3-WindowSize-[9]\n", "");
}
- Assert.assertEquals("0-WindowSize-[119]\n" +
- "3-WindowSize-[119]\n" +
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-length]-[119]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-119\n" +
+ Assert.assertEquals("0-WindowSize-[119]\n" + "3-WindowSize-[119]\n" + "3-HeadersStart\n" +
+ "3-Header-[:status]-[200]\n" + "3-Header-[content-length]-[119]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n" + "3-Body-119\n" +
"3-EndOfStream\n", trace);
} finally {
LogManager.getLogManager().getLogger("org.apache.coyote").setLevel(Level.INFO);
@@ -184,20 +172,16 @@ public class TestHttp2Section_6_1 extends Http2TestBase {
trace = trace.replace(paddingWindowUpdate, "");
// The stream window update may or may not be present depending on
- // timing. Remove it if present.
+ // timing. Remove it if present.
paddingWindowUpdate = "3-WindowSize-[1]\n";
if (trace.contains(paddingWindowUpdate)) {
trace = trace.replace(paddingWindowUpdate, "");
}
- Assert.assertEquals("0-WindowSize-[127]\n" +
- "3-WindowSize-[127]\n" +
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-length]-[127]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-127\n" +
- "3-EndOfStream\n", trace);
+ Assert.assertEquals(
+ "0-WindowSize-[127]\n" + "3-WindowSize-[127]\n" + "3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
+ "3-Header-[content-length]-[127]\n" + "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
+ "3-HeadersEnd\n" + "3-Body-127\n" + "3-EndOfStream\n",
+ trace);
}
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_2.java b/test/org/apache/coyote/http2/TestHttp2Section_6_2.java
index ae9665ca96..9e903ceed9 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_2.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_2.java
@@ -22,11 +22,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 6.2 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 6.2 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_6_2 extends Http2TestBase {
@@ -49,7 +46,7 @@ public class TestHttp2Section_6_2 extends Http2TestBase {
public void testHeaderFrameWithPadding() throws Exception {
http2Connect();
- byte[] padding= new byte[8];
+ byte[] padding = new byte[8];
sendSimpleGetRequest(3, padding);
readSimpleGetResponse();
@@ -61,7 +58,7 @@ public class TestHttp2Section_6_2 extends Http2TestBase {
public void testHeaderFrameWithNonZeroPadding() throws Exception {
http2Connect();
- byte[] padding= new byte[8];
+ byte[] padding = new byte[8];
padding[4] = 1;
sendSimpleGetRequest(3, padding);
@@ -98,7 +95,7 @@ public class TestHttp2Section_6_2 extends Http2TestBase {
public void testHeaderFrameWithZeroLengthPadding() throws Exception {
http2Connect();
- byte[] padding= new byte[0];
+ byte[] padding = new byte[0];
sendSimpleGetRequest(3, padding);
readSimpleGetResponse();
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_3.java b/test/org/apache/coyote/http2/TestHttp2Section_6_3.java
index 0b9c956769..1115f52457 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_3.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_3.java
@@ -22,11 +22,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 6.3 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 6.3 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_6_3 extends Http2TestBase {
@@ -80,7 +77,6 @@ public class TestHttp2Section_6_3 extends Http2TestBase {
// Read reset frame
parser.readFrame();
- Assert.assertEquals("3-RST-[" + Http2Error.FRAME_SIZE_ERROR.getCode() + "]\n",
- output.getTrace());
+ Assert.assertEquals("3-RST-[" + Http2Error.FRAME_SIZE_ERROR.getCode() + "]\n", output.getTrace());
}
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_4.java b/test/org/apache/coyote/http2/TestHttp2Section_6_4.java
index a587294cac..ba0dc64cd1 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_4.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_4.java
@@ -20,11 +20,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 6.4 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 6.4 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_6_4 extends Http2TestBase {
@@ -73,7 +70,6 @@ public class TestHttp2Section_6_4 extends Http2TestBase {
// Read reset frame
parser.readFrame();
- Assert.assertEquals("3-RST-[" + Http2Error.FRAME_SIZE_ERROR.getCode() + "]\n",
- output.getTrace());
+ Assert.assertEquals("3-RST-[" + Http2Error.FRAME_SIZE_ERROR.getCode() + "]\n", output.getTrace());
}
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_5.java b/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
index 306bd89671..f826914013 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_5.java
@@ -20,11 +20,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 6.5 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 6.5 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_6_5 extends Http2TestBase {
@@ -34,7 +31,7 @@ public class TestHttp2Section_6_5 extends Http2TestBase {
// HTTP2 upgrade
http2Connect();
- sendSettings(0, true, new SettingValue(1,1));
+ sendSettings(0, true, new SettingValue(1, 1));
handleGoAwayResponse(1, Http2Error.FRAME_SIZE_ERROR);
}
@@ -46,7 +43,7 @@ public class TestHttp2Section_6_5 extends Http2TestBase {
http2Connect();
sendPriority(3, 0, 15);
- sendSettings(3, true, new SettingValue(1,1));
+ sendSettings(3, true, new SettingValue(1, 1));
handleGoAwayResponse(1);
}
@@ -81,7 +78,7 @@ public class TestHttp2Section_6_5 extends Http2TestBase {
// HTTP2 upgrade
http2Connect();
- sendSettings(0, false, new SettingValue(0x2,0x2));
+ sendSettings(0, false, new SettingValue(0x2, 0x2));
handleGoAwayResponse(1);
}
@@ -92,7 +89,7 @@ public class TestHttp2Section_6_5 extends Http2TestBase {
// HTTP2 upgrade
http2Connect();
- sendSettings(0, false, new SettingValue(0x4,1 << 31));
+ sendSettings(0, false, new SettingValue(0x4, 1 << 31));
handleGoAwayResponse(1, Http2Error.FLOW_CONTROL_ERROR);
}
@@ -103,7 +100,7 @@ public class TestHttp2Section_6_5 extends Http2TestBase {
// HTTP2 upgrade
http2Connect();
- sendSettings(0, false, new SettingValue(0x5,1 << 31));
+ sendSettings(0, false, new SettingValue(0x5, 1 << 31));
handleGoAwayResponse(1);
}
@@ -114,13 +111,12 @@ public class TestHttp2Section_6_5 extends Http2TestBase {
// HTTP2 upgrade
http2Connect();
- sendSettings(0, false, new SettingValue(0xFF,0xFF));
+ sendSettings(0, false, new SettingValue(0xFF, 0xFF));
// Ack
parser.readFrame();
- Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
- "0-Settings-Ack"));
+ Assert.assertTrue(output.getTrace(), output.getTrace().startsWith("0-Settings-Ack"));
}
// delayed ACKs. Requires an API (TBD) for applications to send settings.
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_6.java b/test/org/apache/coyote/http2/TestHttp2Section_6_6.java
index cdf19bbec1..ae61fd31f1 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_6.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_6.java
@@ -36,10 +36,9 @@ import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;
/**
- * Unit tests for Section 6.5 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
+ * Unit tests for Section 6.5 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
*/
-public class TestHttp2Section_6_6 extends Http2TestBase {
+public class TestHttp2Section_6_6 extends Http2TestBase {
@Test
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_7.java b/test/org/apache/coyote/http2/TestHttp2Section_6_7.java
index d9186486fb..cb5422322f 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_7.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_7.java
@@ -22,11 +22,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 6.7 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 6.7 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_6_7 extends Http2TestBase {
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
index b2de519e6b..ae245ca418 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_8.java
@@ -20,11 +20,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 6.8 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 6.8 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_6_8 extends Http2TestBase {
@@ -62,7 +59,7 @@ public class TestHttp2Section_6_8 extends Http2TestBase {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals(getSimpleResponseTrace(3), output.getTrace());
+ Assert.assertEquals(getSimpleResponseTrace(3), output.getTrace());
output.clearTrace();
// Finally the go away frame
@@ -83,5 +80,5 @@ public class TestHttp2Section_6_8 extends Http2TestBase {
// TODO Test header processing and window size processing for ignored
- // streams
+ // streams
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_6_9.java b/test/org/apache/coyote/http2/TestHttp2Section_6_9.java
index 25186671d1..176c669cef 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_6_9.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_6_9.java
@@ -22,11 +22,8 @@ import org.junit.Assert;
import org.junit.Test;
/**
- * Unit tests for Section 6.9 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * requirements in the RFC.
+ * Unit tests for Section 6.9 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the requirements in the RFC.
*/
public class TestHttp2Section_6_9 extends Http2TestBase {
@@ -44,13 +41,12 @@ public class TestHttp2Section_6_9 extends Http2TestBase {
public void testZeroWindowUpdateStream() throws Exception {
http2Connect();
- sendSimplePostRequest(3, null, false);
+ sendSimplePostRequest(3, null, false);
sendWindowUpdate(3, 0);
parser.readFrame();
- Assert.assertEquals("3-RST-[" + Http2Error.PROTOCOL_ERROR.getCode() + "]\n",
- output.getTrace());
+ Assert.assertEquals("3-RST-[" + Http2Error.PROTOCOL_ERROR.getCode() + "]\n", output.getTrace());
}
@@ -69,7 +65,7 @@ public class TestHttp2Section_6_9 extends Http2TestBase {
// TODO: Test always accounting for changes in flow control windows even if
- // the frame is in error.
+ // the frame is in error.
@Test
@@ -114,7 +110,7 @@ public class TestHttp2Section_6_9 extends Http2TestBase {
parser.readFrame();
// Release Stream 15 which is waiting for a single byte.
- sendWindowUpdate(0, 1024);
+ sendWindowUpdate(0, 1024);
Assert.assertEquals(getEmptyResponseTrace(17), output.getTrace());
}
@@ -125,15 +121,14 @@ public class TestHttp2Section_6_9 extends Http2TestBase {
http2Connect();
// Set up stream 3
- sendSimplePostRequest(3, null, false);
+ sendSimplePostRequest(3, null, false);
// Super size the flow control window.
sendWindowUpdate(3, (1 << 31) - 1);
parser.readFrame();
- Assert.assertEquals("3-RST-[" + Http2Error.FLOW_CONTROL_ERROR.getCode() + "]\n",
- output.getTrace());
+ Assert.assertEquals("3-RST-[" + Http2Error.FLOW_CONTROL_ERROR.getCode() + "]\n", output.getTrace());
}
@@ -161,8 +156,7 @@ public class TestHttp2Section_6_9 extends Http2TestBase {
byte[] dataFrameHeader = new byte[9];
ByteBuffer dataPayload = ByteBuffer.allocate(8 * 1024);
- buildPostRequest(headersFrameHeader, headersPayload, false,
- dataFrameHeader, dataPayload, null, 3);
+ buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload, null, 3);
// Write the headers
writeFrame(headersFrameHeader, headersPayload);
@@ -181,23 +175,17 @@ public class TestHttp2Section_6_9 extends Http2TestBase {
// Window size updates after reading POST body
parser.readFrame();
parser.readFrame();
- Assert.assertEquals(
- "0-WindowSize-[8192]\n" +
- "3-WindowSize-[8192]\n",
- output.getTrace());
+ Assert.assertEquals("0-WindowSize-[8192]\n" + "3-WindowSize-[8192]\n", output.getTrace());
output.clearTrace();
// Read stream 3 headers and first part of body
parser.readFrame();
parser.readFrame();
Assert.assertEquals(
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-length]-[8192]\n" +
- "3-Header-[date]-["+ DEFAULT_DATE + "]\n" +
- "3-HeadersEnd\n" +
- "3-Body-4096\n", output.getTrace());
- output.clearTrace();
+ "3-HeadersStart\n" + "3-Header-[:status]-[200]\n" + "3-Header-[content-length]-[8192]\n" +
+ "3-Header-[date]-[" + DEFAULT_DATE + "]\n" + "3-HeadersEnd\n" + "3-Body-4096\n",
+ output.getTrace());
+ output.clearTrace();
// Now use a settings frame to further reduce the size of the flow
// control window. This should make the stream 3 window negative
@@ -220,23 +208,15 @@ public class TestHttp2Section_6_9 extends Http2TestBase {
// Window size updates after reading POST body
parser.readFrame();
parser.readFrame();
- Assert.assertEquals(
- "0-WindowSize-[128]\n" +
- "5-WindowSize-[128]\n",
- output.getTrace());
+ Assert.assertEquals("0-WindowSize-[128]\n" + "5-WindowSize-[128]\n", output.getTrace());
output.clearTrace();
// Headers + body
parser.readFrame();
parser.readFrame();
- Assert.assertEquals(
- "5-HeadersStart\n" +
- "5-Header-[:status]-[200]\n" +
- "5-Header-[content-length]-[128]\n" +
- "5-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "5-HeadersEnd\n" +
- "5-Body-128\n" +
+ Assert.assertEquals("5-HeadersStart\n" + "5-Header-[:status]-[200]\n" + "5-Header-[content-length]-[128]\n" +
+ "5-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "5-HeadersEnd\n" + "5-Body-128\n" +
"5-EndOfStream\n", output.getTrace());
- output.clearTrace();
+ output.clearTrace();
// Now use a settings frame to restore the size of the flow control
// window.
@@ -270,17 +250,16 @@ public class TestHttp2Section_6_9 extends Http2TestBase {
http2Connect();
// Set up stream 3
- sendSimplePostRequest(3, null, false);
+ sendSimplePostRequest(3, null, false);
// Increase the flow control window but keep it under the limit
sendWindowUpdate(3, 1 << 30);
// Now increase beyond the limit via a settings frame
- sendSettings(0, false, new SettingValue(4, 1 << 30));
+ sendSettings(0, false, new SettingValue(4, 1 << 30));
// Ack
parser.readFrame();
- Assert.assertEquals("3-RST-[" + Http2Error.FLOW_CONTROL_ERROR.getCode() + "]\n",
- output.getTrace());
+ Assert.assertEquals("3-RST-[" + Http2Error.FLOW_CONTROL_ERROR.getCode() + "]\n", output.getTrace());
}
}
diff --git a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
index e76bfd869a..5bc3e3872e 100644
--- a/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
+++ b/test/org/apache/coyote/http2/TestHttp2Section_8_1.java
@@ -29,11 +29,8 @@ import org.apache.coyote.ContinueResponseTiming;
import org.apache.coyote.http11.AbstractHttp11Protocol;
/**
- * Unit tests for Section 8.1 of
- * <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>.
- * <br>
- * The order of tests in this class is aligned with the order of the
- * examples in the RFC.
+ * Unit tests for Section 8.1 of <a href="https://tools.ietf.org/html/rfc7540">RFC 7540</a>. <br>
+ * The order of tests in this class is aligned with the order of the examples in the RFC.
*/
public class TestHttp2Section_8_1 extends Http2TestBase {
@@ -49,10 +46,11 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
}
- private void doTestPostWithTrailerHeaders(boolean allowTrailerHeader) throws Exception{
+ private void doTestPostWithTrailerHeaders(boolean allowTrailerHeader) throws Exception {
http2Connect();
if (allowTrailerHeader) {
- ((AbstractHttp11Protocol<?>) http2Protocol.getHttp11Protocol()).setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
+ ((AbstractHttp11Protocol<?>) http2Protocol.getHttp11Protocol())
+ .setAllowedTrailerHeaders(TRAILER_HEADER_NAME);
}
// Disable overhead protection for window update as it breaks some tests
@@ -65,8 +63,8 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] trailerFrameHeader = new byte[9];
ByteBuffer trailerPayload = ByteBuffer.allocate(256);
- buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload,
- null, trailerFrameHeader, trailerPayload, 3);
+ buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload, null,
+ trailerFrameHeader, trailerPayload, 3);
// Write the headers
writeFrame(headersFrameHeader, headersPayload);
@@ -87,17 +85,9 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
len = "256";
}
- Assert.assertEquals("0-WindowSize-[256]\n" +
- "3-WindowSize-[256]\n" +
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-length]-[" + len + "]\n" +
- "3-Header-[date]-["+ DEFAULT_DATE + "]\n" +
- "3-HeadersEnd\n" +
- "3-Body-" +
- len +
- "\n" +
- "3-EndOfStream\n",
+ Assert.assertEquals("0-WindowSize-[256]\n" + "3-WindowSize-[256]\n" + "3-HeadersStart\n" +
+ "3-Header-[:status]-[200]\n" + "3-Header-[content-length]-[" + len + "]\n" + "3-Header-[date]-[" +
+ DEFAULT_DATE + "]\n" + "3-HeadersEnd\n" + "3-Body-" + len + "\n" + "3-EndOfStream\n",
output.getTrace());
}
@@ -147,20 +137,15 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] dataFrameHeader = new byte[9];
ByteBuffer dataPayload = ByteBuffer.allocate(256);
- buildPostRequest(headersFrameHeader, headersPayload, true,
- null, -1, "/simple",
- dataFrameHeader, dataPayload, null,
- null, null, 3);
+ buildPostRequest(headersFrameHeader, headersPayload, true, null, -1, "/simple", dataFrameHeader, dataPayload,
+ null, null, null, 3);
// Write the headers
writeFrame(headersFrameHeader, headersPayload);
parser.readFrame();
- Assert.assertEquals("3-HeadersStart\n" +
- "3-Header-[:status]-[100]\n" +
- "3-HeadersEnd\n",
- output.getTrace());
+ Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[100]\n" + "3-HeadersEnd\n", output.getTrace());
output.clearTrace();
// Write the body
@@ -171,16 +156,9 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals("0-WindowSize-[256]\n" +
- "3-WindowSize-[256]\n" +
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-length]-[256]\n" +
- "3-Header-[date]-["+ DEFAULT_DATE + "]\n" +
- "3-HeadersEnd\n" +
- "3-Body-256\n" +
- "3-EndOfStream\n",
- output.getTrace());
+ Assert.assertEquals("0-WindowSize-[256]\n" + "3-WindowSize-[256]\n" + "3-HeadersStart\n" +
+ "3-Header-[:status]-[200]\n" + "3-Header-[content-length]-[256]\n" + "3-Header-[date]-[" +
+ DEFAULT_DATE + "]\n" + "3-HeadersEnd\n" + "3-Body-256\n" + "3-EndOfStream\n", output.getTrace());
}
@@ -230,7 +208,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildSimpleGetRequestPart1(headersFrameHeader, headersPayload, headers , 3);
+ buildSimpleGetRequestPart1(headersFrameHeader, headersPayload, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
@@ -238,7 +216,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
headers.add(new Header(":authority", "localhost:" + getPort()));
headersPayload.clear();
- buildSimpleGetRequestPart2(headersFrameHeader, headersPayload, headers , 3);
+ buildSimpleGetRequestPart2(headersFrameHeader, headersPayload, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
@@ -262,7 +240,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(headersFrameHeader, headersPayload, null, headers , 3);
+ buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
@@ -287,7 +265,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(headersFrameHeader, headersPayload, null, headers , 3);
+ buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
@@ -312,7 +290,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(headersFrameHeader, headersPayload, null, headers , 3);
+ buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
@@ -337,7 +315,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(headersFrameHeader, headersPayload, null, headers , 3);
+ buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
@@ -399,7 +377,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(headersFrameHeader, headersPayload, null, headers , 3);
+ buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
@@ -419,7 +397,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(headersFrameHeader, headersPayload, null, headers , 3);
+ buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);
// Write the headers
writeFrame(headersFrameHeader, headersPayload);
@@ -448,7 +426,7 @@ public class TestHttp2Section_8_1 extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(headersFrameHeader, headersPayload, null, headers , 3);
+ buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
diff --git a/test/org/apache/coyote/http2/TestHttp2Timeouts.java b/test/org/apache/coyote/http2/TestHttp2Timeouts.java
index 3768b5888e..4456b704bd 100644
--- a/test/org/apache/coyote/http2/TestHttp2Timeouts.java
+++ b/test/org/apache/coyote/http2/TestHttp2Timeouts.java
@@ -30,8 +30,7 @@ public class TestHttp2Timeouts extends Http2TestBase {
/*
- * Simple request won't fill buffer so timeout will occur in Tomcat internal
- * code during response completion.
+ * Simple request won't fill buffer so timeout will occur in Tomcat internal code during response completion.
*/
@Test
public void testClientWithEmptyWindow() throws Exception {
@@ -51,9 +50,8 @@ public class TestHttp2Timeouts extends Http2TestBase {
/*
- * Large request will fill buffer so timeout will occur in application code
- * during response write (when Tomcat commits the response and flushes the
- * buffer as a result of the buffer filling).
+ * Large request will fill buffer so timeout will occur in application code during response write (when Tomcat
+ * commits the response and flushes the buffer as a result of the buffer filling).
*/
@Test
public void testClientWithEmptyWindowLargeResponse() throws Exception {
@@ -77,7 +75,7 @@ public class TestHttp2Timeouts extends Http2TestBase {
*/
@Test
public void testClientPostsNoBody() throws Exception {
- sendSimplePostRequest(3, null, false);
+ sendSimplePostRequest(3, null, false);
// Headers
parser.readFrame();
diff --git a/test/org/apache/coyote/http2/TestHttp2UpgradeHandler.java b/test/org/apache/coyote/http2/TestHttp2UpgradeHandler.java
index b4565c7c72..da7f9da4c3 100644
--- a/test/org/apache/coyote/http2/TestHttp2UpgradeHandler.java
+++ b/test/org/apache/coyote/http2/TestHttp2UpgradeHandler.java
@@ -58,15 +58,9 @@ public class TestHttp2UpgradeHandler extends Http2TestBase {
// Body
parser.readFrame();
- Assert.assertEquals(
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[x-ignore]-[...]\n" +
- "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
- "3-Header-[content-length]-[2]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-2\n" +
+ Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[200]\n" + "3-Header-[x-ignore]-[...]\n" +
+ "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" + "3-Header-[content-length]-[2]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n" + "3-Body-2\n" +
"3-EndOfStream\n", output.getTrace());
}
@@ -136,14 +130,9 @@ public class TestHttp2UpgradeHandler extends Http2TestBase {
openClientConnection();
- byte[] upgradeRequest = ((usePost ? "POST" : "GET") +
- " /" + (useReader ? "?useReader=true " : " ") + "HTTP/1.1\r\n" +
- "Host: localhost:" + getPort() + "\r\n" +
- "Content-Length: 18\r\n" +
- "Connection: Upgrade,HTTP2-Settings\r\n" +
- "Upgrade: h2c\r\n" +
- EMPTY_HTTP2_SETTINGS_HEADER +
- "\r\n" +
+ byte[] upgradeRequest = ((usePost ? "POST" : "GET") + " /" + (useReader ? "?useReader=true " : " ") +
+ "HTTP/1.1\r\n" + "Host: localhost:" + getPort() + "\r\n" + "Content-Length: 18\r\n" +
+ "Connection: Upgrade,HTTP2-Settings\r\n" + "Upgrade: h2c\r\n" + EMPTY_HTTP2_SETTINGS_HEADER + "\r\n" +
"Small request body").getBytes(StandardCharsets.ISO_8859_1);
os.write(upgradeRequest);
os.flush();
@@ -171,19 +160,11 @@ public class TestHttp2UpgradeHandler extends Http2TestBase {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals("0-Settings-[3]-[200]\n" +
- "0-Settings-End\n" +
- "0-Settings-Ack\n" +
- "0-Ping-[0,0,0,0,0,0,0,1]\n" +
- "1-HeadersStart\n" +
- "1-Header-[:status]-[200]\n" +
- "1-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
- "1-Header-[content-length]-[39]\n" +
- "1-Header-[date]-[" + DEFAULT_DATE + "]\n" +
- "1-HeadersEnd\n" +
- "1-Body-39\n" +
- "1-EndOfStream\n"
- , output.getTrace());
+ Assert.assertEquals("0-Settings-[3]-[200]\n" + "0-Settings-End\n" + "0-Settings-Ack\n" +
+ "0-Ping-[0,0,0,0,0,0,0,1]\n" + "1-HeadersStart\n" + "1-Header-[:status]-[200]\n" +
+ "1-Header-[content-type]-[text/plain;charset=UTF-8]\n" + "1-Header-[content-length]-[39]\n" +
+ "1-Header-[date]-[" + DEFAULT_DATE + "]\n" + "1-HeadersEnd\n" + "1-Body-39\n" + "1-EndOfStream\n",
+ output.getTrace());
}
}
@@ -222,9 +203,8 @@ public class TestHttp2UpgradeHandler extends Http2TestBase {
// 500 response (triggered by IOException trying to read body that never arrived)
parser.readFrame();
- Assert.assertTrue(output.getTrace(), output.getTrace().startsWith(
- stream + "-HeadersStart\n" +
- stream + "-Header-[:status]-[500]\n"));
+ Assert.assertTrue(output.getTrace(),
+ output.getTrace().startsWith(stream + "-HeadersStart\n" + stream + "-Header-[:status]-[500]\n"));
output.clearTrace();
// reset frame
diff --git a/test/org/apache/coyote/http2/TestLargeUpload.java b/test/org/apache/coyote/http2/TestLargeUpload.java
index e52cbdc84d..886f55350a 100644
--- a/test/org/apache/coyote/http2/TestLargeUpload.java
+++ b/test/org/apache/coyote/http2/TestLargeUpload.java
@@ -54,15 +54,12 @@ public class TestLargeUpload extends Http2TestBase {
List<Object[]> parameterSets = new ArrayList<>();
for (Object[] base : baseData) {
- parameterSets.add(new Object[] {
- base[0], base[1],
- "JSSE", Boolean.FALSE, "org.apache.tomcat.util.net.jsse.JSSEImplementation"});
- parameterSets.add(new Object[] {
- base[0], base[1],
- "OpenSSL", Boolean.TRUE, "org.apache.tomcat.util.net.openssl.OpenSSLImplementation"});
- parameterSets.add(new Object[] {
- base[0], base[1],
- "OpenSSL-Panama", Boolean.FALSE, "org.apache.tomcat.util.net.openssl.panama.OpenSSLImplementation"});
+ parameterSets.add(new Object[] { base[0], base[1], "JSSE", Boolean.FALSE,
+ "org.apache.tomcat.util.net.jsse.JSSEImplementation" });
+ parameterSets.add(new Object[] { base[0], base[1], "OpenSSL", Boolean.TRUE,
+ "org.apache.tomcat.util.net.openssl.OpenSSLImplementation" });
+ parameterSets.add(new Object[] { base[0], base[1], "OpenSSL-Panama", Boolean.FALSE,
+ "org.apache.tomcat.util.net.openssl.panama.OpenSSLImplementation" });
}
return parameterSets;
@@ -98,8 +95,8 @@ public class TestLargeUpload extends Http2TestBase {
byte[] trailerFrameHeader = new byte[9];
ByteBuffer trailerPayload = ByteBuffer.allocate(256);
- buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload,
- null, trailerFrameHeader, trailerPayload, 3);
+ buildPostRequest(headersFrameHeader, headersPayload, false, dataFrameHeader, dataPayload, null,
+ trailerFrameHeader, trailerPayload, 3);
// Write the headers
writeFrame(headersFrameHeader, headersPayload);
diff --git a/test/org/apache/coyote/http2/TestStream.java b/test/org/apache/coyote/http2/TestStream.java
index 6cdb581d58..83dc31479f 100644
--- a/test/org/apache/coyote/http2/TestStream.java
+++ b/test/org/apache/coyote/http2/TestStream.java
@@ -60,20 +60,14 @@ public class TestStream extends Http2TestBase {
byte[] frameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(frameHeader, headersPayload, null, 3,
- "/pathparam;jsessionid=" + PathParam.EXPECTED_SESSION_ID);
+ buildGetRequest(frameHeader, headersPayload, null, 3, "/pathparam;jsessionid=" + PathParam.EXPECTED_SESSION_ID);
writeFrame(frameHeader, headersPayload);
readSimpleGetResponse();
- Assert.assertEquals(
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
- "3-Header-[content-length]-[2]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-2\n" +
+ Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
+ "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" + "3-Header-[content-length]-[2]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n" + "3-Body-2\n" +
"3-EndOfStream\n", output.getTrace());
}
@@ -111,18 +105,12 @@ public class TestStream extends Http2TestBase {
parser.readFrame();
Assert.assertEquals(
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
- "3-Header-[content-length]-[44]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-44\n" +
- "3-HeadersStart\n" +
- "3-Header-[x-trailer-2]-[Trailer value two]\n" +
- "3-Header-[x-trailer-1]-[Trailer value one]\n" +
- "3-HeadersEnd\n" +
- "3-EndOfStream\n", output.getTrace());
+ "3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
+ "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" + "3-Header-[content-length]-[44]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n" + "3-Body-44\n" +
+ "3-HeadersStart\n" + "3-Header-[x-trailer-2]-[Trailer value two]\n" +
+ "3-Header-[x-trailer-1]-[Trailer value one]\n" + "3-HeadersEnd\n" + "3-EndOfStream\n",
+ output.getTrace());
}
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java b/test/org/apache/coyote/http2/TestStreamProcessor.java
index 78e84bb57f..4231fd3f3f 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -74,14 +74,9 @@ public class TestStreamProcessor extends Http2TestBase {
// additional frame needs to be read
parser.readFrame();
- Assert.assertEquals(
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
+ Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
"3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-17\n" +
- "3-Body-8\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n" + "3-Body-17\n" + "3-Body-8\n" +
"3-EndOfStream\n", output.getTrace());
}
@@ -539,15 +534,9 @@ public class TestStreamProcessor extends Http2TestBase {
readSimpleGetResponse();
- Assert.assertEquals(
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[vary]-[accept-encoding]\n" +
- "3-Header-[content-encoding]-[gzip]\n" +
- "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-97\n" +
+ Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[200]\n" + "3-Header-[vary]-[accept-encoding]\n" +
+ "3-Header-[content-encoding]-[gzip]\n" + "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n" + "3-Body-97\n" +
"3-EndOfStream\n", output.getTrace());
}
@@ -557,8 +546,7 @@ public class TestStreamProcessor extends Http2TestBase {
private static final long serialVersionUID = 1L;
@Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// Generate content type that is compressible
resp.setContentType("text/plain");
resp.setCharacterEncoding("UTF-8");
@@ -589,7 +577,7 @@ public class TestStreamProcessor extends Http2TestBase {
byte[] headersFrameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(headersFrameHeader, headersPayload, null, headers , 3);
+ buildGetRequest(headersFrameHeader, headersPayload, null, headers, 3);
writeFrame(headersFrameHeader, headersPayload);
diff --git a/test/org/apache/coyote/http2/TestStreamQueryString.java b/test/org/apache/coyote/http2/TestStreamQueryString.java
index be10725426..07dd93e66c 100644
--- a/test/org/apache/coyote/http2/TestStreamQueryString.java
+++ b/test/org/apache/coyote/http2/TestStreamQueryString.java
@@ -55,9 +55,7 @@ public class TestStreamQueryString extends Http2TestBase {
for (Object[] base : baseData) {
// Test ASCII characters from 32 to 126 inclusive
for (int i = 32; i < 128; i++) {
- result.add(new Object[] {
- base[0], base[1],
- "%" + HexUtils.toHexString(new byte[] { (byte) i})});
+ result.add(new Object[] { base[0], base[1], "%" + HexUtils.toHexString(new byte[] { (byte) i }) });
}
}
@@ -89,36 +87,28 @@ public class TestStreamQueryString extends Http2TestBase {
byte[] frameHeader = new byte[9];
ByteBuffer headersPayload = ByteBuffer.allocate(128);
- buildGetRequest(frameHeader, headersPayload, null, 3,
- "/query?" + Query.PARAM_NAME + "=" + queryValue);
+ buildGetRequest(frameHeader, headersPayload, null, 3, "/query?" + Query.PARAM_NAME + "=" + queryValue);
writeFrame(frameHeader, headersPayload);
readSimpleGetResponse();
Assert.assertEquals(queryValue,
- "3-HeadersStart\n" +
- "3-Header-[:status]-[200]\n" +
- "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
- "3-Header-[content-length]-[2]\n" +
- "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "3-HeadersEnd\n" +
- "3-Body-2\n" +
- "3-EndOfStream\n", output.getTrace());
+ "3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
+ "3-Header-[content-type]-[text/plain;charset=UTF-8]\n" + "3-Header-[content-length]-[2]\n" +
+ "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "3-HeadersEnd\n" + "3-Body-2\n" +
+ "3-EndOfStream\n",
+ output.getTrace());
}
protected void doHttpUpgrade(String queryValue) throws IOException {
byte[] upgradeRequest = ("GET /query?" + Query.PARAM_NAME + "=" + queryValue + " HTTP/1.1\r\n" +
- "Host: localhost:" + getPort() + "\r\n" +
- "Connection: "+ DEFAULT_CONNECTION_HEADER_VALUE + "\r\n" +
- "Upgrade: h2c\r\n" +
- EMPTY_HTTP2_SETTINGS_HEADER +
- "\r\n").getBytes(StandardCharsets.ISO_8859_1);
+ "Host: localhost:" + getPort() + "\r\n" + "Connection: " + DEFAULT_CONNECTION_HEADER_VALUE + "\r\n" +
+ "Upgrade: h2c\r\n" + EMPTY_HTTP2_SETTINGS_HEADER + "\r\n").getBytes(StandardCharsets.ISO_8859_1);
os.write(upgradeRequest);
os.flush();
- Assert.assertTrue("Failed to read HTTP Upgrade response",
- readHttpUpgradeResponse());
+ Assert.assertTrue("Failed to read HTTP Upgrade response", readHttpUpgradeResponse());
}
@@ -137,17 +127,10 @@ public class TestStreamQueryString extends Http2TestBase {
parser.readFrame();
parser.readFrame();
- Assert.assertEquals("0-Settings-[3]-[200]\n" +
- "0-Settings-End\n" +
- "0-Settings-Ack\n" +
- "0-Ping-[0,0,0,0,0,0,0,1]\n" +
- "1-HeadersStart\n" +
- "1-Header-[:status]-[200]\n" +
- "1-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
- "1-Header-[content-length]-[2]\n" +
- "1-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" +
- "1-HeadersEnd\n" +
- "1-Body-2\n" +
+ Assert.assertEquals("0-Settings-[3]-[200]\n" + "0-Settings-End\n" + "0-Settings-Ack\n" +
+ "0-Ping-[0,0,0,0,0,0,0,1]\n" + "1-HeadersStart\n" + "1-Header-[:status]-[200]\n" +
+ "1-Header-[content-type]-[text/plain;charset=UTF-8]\n" + "1-Header-[content-length]-[2]\n" +
+ "1-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + "1-HeadersEnd\n" + "1-Body-2\n" +
"1-EndOfStream\n", output.getTrace());
output.clearTrace();
diff --git a/test/org/apache/coyote/http2/TesterHttp2Parser.java b/test/org/apache/coyote/http2/TesterHttp2Parser.java
index ee0a4b3b1d..3b4f10af39 100644
--- a/test/org/apache/coyote/http2/TesterHttp2Parser.java
+++ b/test/org/apache/coyote/http2/TesterHttp2Parser.java
@@ -37,8 +37,7 @@ public class TesterHttp2Parser extends Http2Parser {
/**
* {@inheritDoc}
* <p>
- * <b>Note:</b> The test implementation always uses blocking IO for both the
- * initial read and the remainder.
+ * <b>Note:</b> The test implementation always uses blocking IO for both the initial read and the remainder.
*/
@Override
public boolean readFrame() throws Http2Exception, IOException {
@@ -46,7 +45,8 @@ public class TesterHttp2Parser extends Http2Parser {
}
@Override
- protected void readPushPromiseFrame(int streamId, int flags, int payloadSize, ByteBuffer buffer) throws Http2Exception, IOException {
+ protected void readPushPromiseFrame(int streamId, int flags, int payloadSize, ByteBuffer buffer)
+ throws Http2Exception, IOException {
// Parse flags used in this method
boolean hasPadding = Flags.hasPadding(flags);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org