Permalink
Browse files

Fix for #195 [runtime] Add support for Tomcat WebSocket

  • Loading branch information...
jfarcand committed Apr 6, 2012
1 parent a26ae4c commit 380b5715af327270a0033bb06018bd73d71e8334
Showing with 608 additions and 104 deletions.
  1. +132 −0 modules/acceptance-tests/pom.xml
  2. 0 ...es/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/AbstractHttpAtmosphereHandler.java
  3. 0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/AtmosphereServletTest.java
  4. +16 −16 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/BaseTest.java
  5. 0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/BlockingIOCometSupportTest.java
  6. 0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/BroadcasterLifecycleTest.java
  7. 0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/BroadcasterScopeTest.java
  8. 0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/ConcurrentBroadcastTest.java
  9. 0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/GrizzlyCometSupportTest.java
  10. 0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/Jetty6CometSupportTest.java
  11. 0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/Jetty7CometSupportTest.java
  12. +0 −1 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/MeteorTest.java
  13. +5 −0 modules/{cpr → acceptance-tests}/src/test/java/org/atmosphere/tests/TomcatCometSupportTest.java
  14. 0 modules/{cpr → acceptance-tests}/src/test/resources/logback-test.xml
  15. +2 −1 modules/compat-tomcat7/pom.xml
  16. +34 −55 modules/cpr/pom.xml
  17. +2 −2 modules/cpr/src/main/java/org/atmosphere/container/JettyWebSocketHandler.java
  18. +173 −0 modules/cpr/src/main/java/org/atmosphere/container/Tomcat7AsyncSupportWithWebSocket.java
  19. +92 −0 modules/cpr/src/main/java/org/atmosphere/container/TomcatWebSocketHandler.java
  20. +108 −0 modules/cpr/src/main/java/org/atmosphere/container/version/TomcatWebSocket.java
  21. +6 −2 modules/cpr/src/main/java/org/atmosphere/cpr/AtmosphereRequest.java
  22. +5 −0 modules/cpr/src/main/java/org/atmosphere/cpr/DefaultAsyncSupportResolver.java
  23. +29 −24 modules/cpr/src/main/java/org/atmosphere/websocket/WebSocketProcessor.java
  24. +1 −1 modules/cpr/src/test/java/org/atmosphere/cpr/DefaultBroadcasterFactoryTest.java
  25. +1 −0 modules/pom.xml
  26. +2 −2 pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-project</artifactId>
+ <version>0.9-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>acceptance-tests-runtime</artifactId>
+ <packaging>jar</packaging>
+ <version>0.9-SNAPSHOT</version>
+ <name>acceptance-tests-runtime</name>
+ <url>https://github.com/Atmosphere/atmosphere</url>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-continuation</artifactId>
+ <version>${jetty7-version}</version>
+ <scope>test</scope>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>${jetty7-version}</version>
+ <scope>test</scope>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.grizzly</groupId>
+ <artifactId>grizzly-websockets</artifactId>
+ <version>${grizzly-version}</version>
+ <scope>test</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.grizzly</groupId>
+ <artifactId>grizzly-http</artifactId>
+ <version>${grizzly-version}</version>
+ <scope>test</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.grizzly</groupId>
+ <artifactId>grizzly-http-servlet</artifactId>
+ <version>${grizzly-version}</version>
+ <scope>test</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.grizzly</groupId>
+ <artifactId>grizzly-comet</artifactId>
+ <version>${grizzly-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.grizzly</groupId>
+ <artifactId>grizzly-compat</artifactId>
+ <version>${grizzly-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>${tomcat-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>coyote</artifactId>
+ <version>${tomcat-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.8.5</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-runtime</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-catalina</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-coyote</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-util</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
+
@@ -216,7 +216,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -268,7 +268,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -320,7 +320,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -392,7 +392,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -474,7 +474,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -550,7 +550,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -623,7 +623,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -704,7 +704,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -784,7 +784,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -858,7 +858,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
event.getResource().resume();
latch.countDown();
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -939,7 +939,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -1006,7 +1006,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -1065,7 +1065,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown();
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -1132,7 +1132,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
assertEquals(event.getMessage(), "broadcastOnResume");
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -1209,7 +1209,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
}
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -1276,7 +1276,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
}
}
}
- }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
+ }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));
AsyncHttpClient c = new AsyncHttpClient();
try {
@@ -35,7 +35,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.servlet.http.HttpServlet;
@@ -85,6 +85,7 @@ public void init(final ServletConfig sc) throws ServletException {
public void startServer() throws Exception {
System.setProperty("org.atmosphere.useNative", "true");
+ try {
int port = TestHelper.getEnvVariable("ATMOSPHERE_HTTP_PORT", findFreePort());
urlTarget = "http://127.0.0.1:" + port + "/invoke";
@@ -114,7 +115,11 @@ public void startServer() throws Exception {
embedded.addEngine(engine);
embedded.addConnector(connector);
embedded.start();
+
atmoServlet = (AtmosphereServlet) w.getServlet();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
}
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-project</artifactId>
Oops, something went wrong.

0 comments on commit 380b571

Please sign in to comment.