Author: remm
Date: Wed Apr  1 15:29:06 2015
New Revision: 1670675

URL: http://svn.apache.org/r1670675
Log:
Since the NB test is one of those having the most issues, add a keepalive 
variant I used to validate that the state is right after a request.

Modified:
    tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java

Modified: 
tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java?rev=1670675&r1=1670674&r2=1670675&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 
(original)
+++ tomcat/trunk/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java 
Wed Apr  1 15:29:06 2015
@@ -118,6 +118,15 @@ public class TestNonBlockingAPI extends
 
     @Test
     public void testNonBlockingWrite() throws Exception {
+        testNonBlockingWriteInternal(false);
+    }
+
+    @Test
+    public void testNonBlockingWriteWithKeepAlive() throws Exception {
+        testNonBlockingWriteInternal(true);
+    }
+
+    private void testNonBlockingWriteInternal(boolean keepAlive) throws 
Exception {
         Tomcat tomcat = getTomcatInstance();
         // No file system docBase required
         Context ctx = tomcat.addContext("", null);
@@ -132,17 +141,25 @@ public class TestNonBlockingAPI extends
         SocketFactory factory = SocketFactory.getDefault();
         Socket s = factory.createSocket("localhost", getPort());
 
+        InputStream is = s.getInputStream();
+        byte[] buffer = new byte[8192];
+
         ByteChunk result = new ByteChunk();
+
         OutputStream os = s.getOutputStream();
+        if (keepAlive) {
+            os.write(("OPTIONS * HTTP/1.1\r\n" +
+                    "Host: localhost:" + getPort() + "\r\n" +
+                    "\r\n").getBytes(StandardCharsets.ISO_8859_1));
+            os.flush();
+            is.read(buffer);
+        }
         os.write(("GET / HTTP/1.1\r\n" +
                 "Host: localhost:" + getPort() + "\r\n" +
                 "Connection: close\r\n" +
                 "\r\n").getBytes(StandardCharsets.ISO_8859_1));
         os.flush();
 
-        InputStream is = s.getInputStream();
-        byte[] buffer = new byte[8192];
-
         int read = 0;
         int readSinceLastPause = 0;
         while (read != -1) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to