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

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


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

commit d31a193827b90c91c9d728a733c1a447b0647b12
Author: Mark Thomas <ma...@apache.org>
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 6650d3c..3790d00 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 ccdc085..dc0fd04 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;
@@ -1125,6 +1123,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.
@@ -1142,11 +1165,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);
@@ -1168,12 +1187,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: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to