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 a969108  Expand test cases. Remove debug logging.
a969108 is described below

commit a9691087718618262b19e4cf44581466a138d724
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 e242917..a650ea7 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 0578b5f..6bb20ee 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;
 
@@ -1122,6 +1120,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.
@@ -1139,11 +1162,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);
@@ -1165,12 +1184,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