This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new 2433979 Improve unit test robustness 2433979 is described below commit 2433979564c0b99f4d3b8fb5214782264dfa5ce0 Author: Mark Thomas <ma...@apache.org> AuthorDate: Sat Nov 16 13:59:58 2019 +0000 Improve unit test robustness --- .../connector/TestCoyoteAdapterRequestFuzzing.java | 17 +++++++++++++++++ test/org/apache/catalina/startup/SimpleHttpClient.java | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java b/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java index acd01a7..dc8ac5e 100644 --- a/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java +++ b/test/org/apache/catalina/connector/TestCoyoteAdapterRequestFuzzing.java @@ -16,7 +16,11 @@ */ package org.apache.catalina.connector; +import java.io.BufferedOutputStream; import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.Socket; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -135,6 +139,19 @@ public class TestCoyoteAdapterRequestFuzzing extends TomcatBaseTest { } @Override + protected OutputStream createOutputStream(Socket socket) throws IOException { + // Override the default implementation so we can create a large + // enough buffer to hold the entire request. + // The default implementation uses the 8k buffer in the + // StreamEncoder. Since some requests are larger than this, those + // requests will be sent in several parts. If the first part is + // sufficient for Tomcat to determine the request is invalid, Tomcat + // will close the connection, causing the write of the remaining + // parts to fail which in turn causes the test to fail. + return new BufferedOutputStream(super.createOutputStream(socket), 32 * 1024); + } + + @Override public boolean isResponseBodyOK() { // Response body varies. It is the response code that is of interest // in these tests. diff --git a/test/org/apache/catalina/startup/SimpleHttpClient.java b/test/org/apache/catalina/startup/SimpleHttpClient.java index 6ff2050..a5ced3e 100644 --- a/test/org/apache/catalina/startup/SimpleHttpClient.java +++ b/test/org/apache/catalina/startup/SimpleHttpClient.java @@ -188,7 +188,7 @@ public abstract class SimpleHttpClient { socket = new Socket(); socket.setSoTimeout(soTimeout); socket.connect(addr,connectTimeout); - OutputStream os = socket.getOutputStream(); + OutputStream os = createOutputStream(socket); writer = new OutputStreamWriter(os, encoding); InputStream is = socket.getInputStream(); Reader r = new InputStreamReader(is, encoding); @@ -198,6 +198,10 @@ public abstract class SimpleHttpClient { connect(0,0); } + protected OutputStream createOutputStream(Socket socket) throws IOException { + return socket.getOutputStream(); + } + public void processRequest() throws IOException, InterruptedException { processRequest(true); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org