This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new 8d8a28c Improve unit test robustness
8d8a28c is described below
commit 8d8a28c98c8785044abdb9113a478eaee52d635b
Author: Mark Thomas <[email protected]>
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 a34adc5..b998ba1 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 dd02566..5d4366e 100644
--- a/test/org/apache/catalina/startup/SimpleHttpClient.java
+++ b/test/org/apache/catalina/startup/SimpleHttpClient.java
@@ -183,7 +183,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);
@@ -193,6 +193,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: [email protected]
For additional commands, e-mail: [email protected]