Modify test to account for behaviours of different platforms and different connectors.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 20 Sep 2011 18:17:06 +0000 (18:17 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 20 Sep 2011 18:17:06 +0000 (18:17 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1173288 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/catalina/comet/TestCometProcessor.java

index b1916bb..c6c6105 100644 (file)
@@ -30,7 +30,6 @@ import javax.servlet.http.HttpSession;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
@@ -152,6 +151,8 @@ public class TestCometProcessor extends TomcatBaseTest {
         Thread.sleep(3000);
         
         tomcat.getConnector().stop();
+        // Allow the executor a chance to send the end event
+        Thread.sleep(100);
         tomcat.getConnector().destroy();
 
         // Wait for the write thread to stop
@@ -171,9 +172,11 @@ public class TestCometProcessor extends TomcatBaseTest {
         // socket should be closed
         assertNotNull("No exception in writing thread",
                 writeThread.getException());
-        // Read should terminate gracefully with an EOF
-        assertNull("Read thread terminated with an exception",
-                readThread.getException());
+
+        // Termination of Read thread varies by platform and protocol
+        // In all cases, the END event should be sent.
+        assertTrue("Comet END event not received",
+                readThread.getResponse().contains("Client: END"));
     }
 
     private boolean isCometSupported() {
@@ -261,7 +264,6 @@ public class TestCometProcessor extends TomcatBaseTest {
 
         private InputStream is;
         private StringBuilder response = new StringBuilder();
-        private volatile Exception e = null;
 
         public ResponseReaderThread(InputStream is) {
             this.is = is;
@@ -271,10 +273,6 @@ public class TestCometProcessor extends TomcatBaseTest {
             return response.toString();
         }
 
-        public Exception getException() {
-            return e;
-        }
-
         @Override
         public void run() {
             try {
@@ -284,7 +282,7 @@ public class TestCometProcessor extends TomcatBaseTest {
                     c = is.read();
                 }
             } catch (Exception e) {
-                this.e = e;
+                // Ignore
             }
         }
     }