Skip to content

Commit

Permalink
Fix for Atmosphere#195 [runtime] Add support for Tomcat WebSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Apr 6, 2012
1 parent a26ae4c commit 380b571
Show file tree
Hide file tree
Showing 26 changed files with 608 additions and 104 deletions.
132 changes: 132 additions & 0 deletions modules/acceptance-tests/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>

Expand Up @@ -216,7 +216,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -268,7 +268,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -320,7 +320,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -392,7 +392,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -474,7 +474,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -550,7 +550,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -623,7 +623,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -704,7 +704,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -784,7 +784,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -858,7 +858,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
event.getResource().resume(); event.getResource().resume();
latch.countDown(); latch.countDown();
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -939,7 +939,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -1006,7 +1006,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -1065,7 +1065,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
latch.countDown(); latch.countDown();
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -1132,7 +1132,7 @@ public void onStateChange(AtmosphereResourceEvent event) throws IOException {
assertEquals(event.getMessage(), "broadcastOnResume"); assertEquals(event.getMessage(), "broadcastOnResume");
} }
} }
}, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend")); }, BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, "suspend"));


AsyncHttpClient c = new AsyncHttpClient(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -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(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down Expand Up @@ -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(); AsyncHttpClient c = new AsyncHttpClient();
try { try {
Expand Down
Expand Up @@ -35,7 +35,6 @@
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;


import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
Expand Down
Expand Up @@ -85,6 +85,7 @@ public void init(final ServletConfig sc) throws ServletException {
public void startServer() throws Exception { public void startServer() throws Exception {


System.setProperty("org.atmosphere.useNative", "true"); System.setProperty("org.atmosphere.useNative", "true");
try {


int port = TestHelper.getEnvVariable("ATMOSPHERE_HTTP_PORT", findFreePort()); int port = TestHelper.getEnvVariable("ATMOSPHERE_HTTP_PORT", findFreePort());
urlTarget = "http://127.0.0.1:" + port + "/invoke"; urlTarget = "http://127.0.0.1:" + port + "/invoke";
Expand Down Expand Up @@ -114,7 +115,11 @@ public void startServer() throws Exception {
embedded.addEngine(engine); embedded.addEngine(engine);
embedded.addConnector(connector); embedded.addConnector(connector);
embedded.start(); embedded.start();

atmoServlet = (AtmosphereServlet) w.getServlet(); atmoServlet = (AtmosphereServlet) w.getServlet();
} catch (Throwable t) {
t.printStackTrace();
}


} }


Expand Down
3 changes: 2 additions & 1 deletion modules/compat-tomcat7/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?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> <parent>
<groupId>org.atmosphere</groupId> <groupId>org.atmosphere</groupId>
<artifactId>atmosphere-project</artifactId> <artifactId>atmosphere-project</artifactId>
Expand Down

0 comments on commit 380b571

Please sign in to comment.