[tomcat] branch 9.0.x updated: Expand test cases. Remove debug logging.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[tomcat] branch 9.0.x updated: Expand test cases. Remove debug logging.

markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new b3559ca  Expand test cases. Remove debug logging.
b3559ca is described below

commit b3559ca81359ca0526ebe78b9277301e745c5307
Author: Mark Thomas <[hidden email]>
AuthorDate: Thu Feb 18 19:01:30 2021 +0000

    Expand test cases. Remove debug logging.
---
 .../apache/catalina/core/TestAsyncContextImpl.java | 35 ++++++++++++++-----
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 40 +++++++++++++++-------
 2 files changed, 54 insertions(+), 21 deletions(-)

diff --git a/test/org/apache/catalina/core/TestAsyncContextImpl.java b/test/org/apache/catalina/core/TestAsyncContextImpl.java
index 761bf49..e1672d3 100644
--- a/test/org/apache/catalina/core/TestAsyncContextImpl.java
+++ b/test/org/apache/catalina/core/TestAsyncContextImpl.java
@@ -3018,6 +3018,31 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
     }
 
 
+    @Test
+    public void testCanceledPostChunked() throws Exception {
+        doTestCanceledPost(new String[] {
+                "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
+                "Host: localhost:" + SimpleHttpClient.CRLF +
+                "Transfer-Encoding: Chunked" + SimpleHttpClient.CRLF +
+                SimpleHttpClient.CRLF +
+                "10" + SimpleHttpClient.CRLF +
+                "This is 16 bytes" + SimpleHttpClient.CRLF
+                });
+    }
+
+
+    @Test
+    public void testCanceledPostNoChunking() throws Exception {
+        doTestCanceledPost(new String[] {
+                "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
+                "Host: localhost:" + SimpleHttpClient.CRLF +
+                "Content-Length: 100" + SimpleHttpClient.CRLF +
+                SimpleHttpClient.CRLF +
+                "This is 16 bytes"
+                });
+    }
+
+
     /*
      * Tests an error on an async thread when the client closes the connection
      * before fully writing the request body.
@@ -3035,8 +3060,7 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
      * would normally be considered very poor practice. It is only safe in this
      * test as the Servlet only processes a single request.
      */
-    @Test
-    public void testCanceledPost() throws Exception {
+    private void doTestCanceledPost(String[] request) throws Exception {
         CountDownLatch partialReadLatch = new CountDownLatch(1);
         CountDownLatch clientCloseLatch = new CountDownLatch(1);
         CountDownLatch threadCompleteLatch = new CountDownLatch(1);
@@ -3058,12 +3082,7 @@ public class TestAsyncContextImpl extends TomcatBaseTest {
 
         PostClient client = new PostClient();
         client.setPort(getPort());
-        client.setRequest(new String[] { "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
-                                         "Host: localhost:" + SimpleHttpClient.CRLF +
-                                         "Content-Length: 100" + SimpleHttpClient.CRLF +
-                                         SimpleHttpClient.CRLF +
-                                         "This is 16 bytes"
-                                         });
+        client.setRequest(request);
         client.connect();
         client.sendRequest();
 
diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index 64d6397..6a6d478 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -34,8 +34,6 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Level;
-import java.util.logging.LogManager;
 
 import javax.net.SocketFactory;
 import javax.servlet.AsyncContext;
@@ -1121,6 +1119,31 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
     }
 
 
+    @Test
+    public void testCanceledPostChunked() throws Exception {
+        doTestCanceledPost(new String[] {
+                "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
+                "Host: localhost:" + SimpleHttpClient.CRLF +
+                "Transfer-Encoding: Chunked" + SimpleHttpClient.CRLF +
+                SimpleHttpClient.CRLF +
+                "10" + SimpleHttpClient.CRLF +
+                "This is 16 bytes" + SimpleHttpClient.CRLF
+                });
+    }
+
+
+    @Test
+    public void testCanceledPostNoChunking() throws Exception {
+        doTestCanceledPost(new String[] {
+                "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
+                "Host: localhost:" + SimpleHttpClient.CRLF +
+                "Content-Length: 100" + SimpleHttpClient.CRLF +
+                SimpleHttpClient.CRLF +
+                "This is 16 bytes"
+                });
+    }
+
+
     /*
      * Tests an error on an non-blocking read when the client closes the
      * connection before fully writing the request body.
@@ -1138,11 +1161,7 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
      * would normally be considered very poor practice. It is only safe in this
      * test as the Servlet only processes a single request.
      */
-    @Test
-    public void testCanceledPost() throws Exception {
-
-        LogManager.getLogManager().getLogger("org.apache.coyote").setLevel(Level.ALL);
-        LogManager.getLogManager().getLogger("org.apache.tomcat.util.net").setLevel(Level.ALL);
+    private void doTestCanceledPost(String[] request) throws Exception {
 
         CountDownLatch partialReadLatch = new CountDownLatch(1);
         CountDownLatch completeLatch = new CountDownLatch(1);
@@ -1164,12 +1183,7 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 
         PostClient client = new PostClient();
         client.setPort(getPort());
-        client.setRequest(new String[] { "POST / HTTP/1.1" + SimpleHttpClient.CRLF +
-                                         "Host: localhost:" + SimpleHttpClient.CRLF +
-                                         "Content-Length: 100" + SimpleHttpClient.CRLF +
-                                         SimpleHttpClient.CRLF +
-                                         "This is 16 bytes"
-                                         });
+        client.setRequest(request);
         client.connect();
         client.sendRequest();
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]