tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r960083 - /tomcat/trunk/test/org/apache/catalina/core/TestAsyncListener.java
Date Fri, 02 Jul 2010 18:30:34 GMT
Author: pero
Date: Fri Jul  2 18:30:34 2010
New Revision: 960083

URL: http://svn.apache.org/viewvc?rev=960083&view=rev
Log:
Test NIO AsyncListener timeout.

Modified:
    tomcat/trunk/test/org/apache/catalina/core/TestAsyncListener.java

Modified: tomcat/trunk/test/org/apache/catalina/core/TestAsyncListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestAsyncListener.java?rev=960083&r1=960082&r2=960083&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/core/TestAsyncListener.java (original)
+++ tomcat/trunk/test/org/apache/catalina/core/TestAsyncListener.java Fri Jul  2 18:30:34
2010
@@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
+import org.apache.catalina.connector.Connector;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
 import org.apache.tomcat.util.buf.ByteChunk;
@@ -44,8 +45,38 @@ public class TestAsyncListener extends T
 
     public void testTimeout() throws Exception {
         // Setup Tomcat instance
+        Tomcat tomcat = getTomcatInstance();        
+
+        TimeoutServlet timeout = createTimeoutTestApp(tomcat);
+        tomcat.start();
+        checkTimeoutRequest(timeout);
+    }
+
+    public void testNIOTimeout() throws Exception {
+        // Setup Tomcat instance with NIO Connector
         Tomcat tomcat = getTomcatInstance();
+        Connector nioConnector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
+        nioConnector.setPort(getNextPort());
+        tomcat.getService().addConnector(nioConnector);
         
+        TimeoutServlet timeout = createTimeoutTestApp(tomcat);
+
+        tomcat.start();
+        checkTimeoutRequest(timeout);
+    }
+    
+    private void checkTimeoutRequest(TimeoutServlet timeout)
+            throws IOException, InterruptedException {
+        ByteChunk res = getUrl("http://localhost:" + getPort() + "/async");
+        Thread.sleep(4000);
+        assertEquals(1,timeout.getAsyncTimeout());
+        //assertEquals(1,timeout.getAsyncStart());
+        assertEquals(1,timeout.getAsyncComplete());
+        //assertEquals("hello start: " + timeout.getStart() + "\n", res.toString());
+        assertNull(res.toString());
+    }
+    
+    private TimeoutServlet createTimeoutTestApp(Tomcat tomcat) {
         // Must have a real docBase - just use temp
         File docBase = new File(System.getProperty("java.io.tmpdir"));
         
@@ -62,15 +93,7 @@ public class TestAsyncListener extends T
         Wrapper wrapper = Tomcat.addServlet(ctx, "time", timeout);
         wrapper.setAsyncSupported(true);
         ctx.addServletMapping("/async", "time");
-
-        tomcat.start();
-        ByteChunk res = getUrl("http://localhost:" + getPort() + "/async");
-        Thread.sleep(4000);
-        assertEquals(1,timeout.getAsyncTimeout());
-        //assertEquals(1,timeout.getAsyncStart());
-        assertEquals(1,timeout.getAsyncComplete());
-        //assertEquals("hello start: " + timeout.getStart() + "\n", res.toString());
-        assertNull(res.toString());
+        return timeout;
     }
     
     private static class TimeoutServlet extends HttpServlet {



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


Mime
View raw message