Skip to content
Browse files

Added an integration test using htmlunit with websockets from http://…

  • Loading branch information...
1 parent a28c0f0 commit 3933c4a6319bec66dd22e78c9bbbd278d8be5206 @aslakhellesoy committed Feb 13, 2011
View
1 .gitignore
@@ -2,3 +2,4 @@ target
*.ipr
*.iml
*.iws
+.DS_Store
View
5 lib/net/sourceforge/htmlunit/htmlunit-websocket/2.9-SNAPSHOT/_maven.repositories
@@ -1,5 +0,0 @@
-#NOTE: This is an internal implementation file, its format can be changed without prior notice.
-#Tue Feb 08 16:38:37 AST 2011
-htmlunit-websocket-2.9-SNAPSHOT.pom>=
-htmlunit-websocket-2.9-SNAPSHOT-sources.jar>=
-htmlunit-websocket-2.9-SNAPSHOT.jar>=
View
5 lib/net/sourceforge/htmlunit/htmlunit/2.9-SNAPSHOT/_maven.repositories
@@ -0,0 +1,5 @@
+#NOTE: This is an internal implementation file, its format can be changed without prior notice.
+#Sun Feb 13 08:50:36 AST 2011
+htmlunit-2.9-SNAPSHOT.pom>=
+htmlunit-2.9-SNAPSHOT-sources.jar>=
+htmlunit-2.9-SNAPSHOT.jar>=
View
BIN lib/net/sourceforge/htmlunit/htmlunit/2.9-SNAPSHOT/htmlunit-2.9-SNAPSHOT-sources.jar
Binary file not shown.
View
BIN ...PSHOT/htmlunit-websocket-2.9-SNAPSHOT.jar → ...it/2.9-SNAPSHOT/htmlunit-2.9-SNAPSHOT.jar
Binary file not shown.
View
10 lib/net/sourceforge/htmlunit/htmlunit/2.9-SNAPSHOT/htmlunit-2.9-SNAPSHOT.jar.lastUpdated
@@ -0,0 +1,10 @@
+#NOTE: This is an internal implementation file, its format can be changed without prior notice.
+#Sun Feb 13 08:46:51 AST 2011
+http\://google-gson.googlecode.com/svn/mavenrepo/.lastUpdated=1297601206938
+http\://google-gson.googlecode.com/svn/mavenrepo/.error=
+http\://oss.sonatype.org/content/repositories/releases/.error=
+http\://oss.sonatype.org/content/repositories/releases/.lastUpdated=1297601207232
+file\:///Users/ahellesoy/scm/dnode-java/dnode/lib/.error=
+http\://repository.jboss.org/nexus/content/groups/public/.error=
+http\://repository.jboss.org/nexus/content/groups/public/.lastUpdated=1297601211367
+file\:///Users/ahellesoy/scm/dnode-java/dnode/lib/.lastUpdated=1297601204904
View
76 ...PSHOT/htmlunit-websocket-2.9-SNAPSHOT.pom → ...it/2.9-SNAPSHOT/htmlunit-2.9-SNAPSHOT.pom
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.htmlunit</groupId>
- <artifactId>htmlunit-websocket</artifactId>
+ <artifactId>htmlunit</artifactId>
<version>2.9-SNAPSHOT</version>
<name>HtmlUnit</name>
<organization>
@@ -761,11 +761,34 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.26</version>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
+ <version>7.1.6.v20100715</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>7.1.6.v20100715</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>7.1.6.v20100715</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <version>7.1.6.v20100715</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-websocket</artifactId>
+ <version>7.1.6.v20100715</version>
+ <scope>test</scope>
+ </dependency>
<!-- The presence of slf4j on the classpath during the unit tests triggers correct logging in Jetty. -->
<dependency>
<groupId>org.slf4j</groupId>
@@ -798,7 +821,7 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
<version>2.0b1</version>
@@ -810,25 +833,6 @@
<version>2.0b1</version>
<scope>test</scope>
</dependency>
- <!-- For testing WebSocket -->
- <dependency>
- <groupId>webbit</groupId>
- <artifactId>webbit</artifactId>
- <version>0.0.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.netty</groupId>
- <artifactId>netty</artifactId>
- <version>3.2.3.Final</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>1.6</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<distributionManagement>
<site>
@@ -882,19 +886,17 @@
<layout>default</layout>
</repository>
<repository>
- <id>Sonatype</id>
- <url>http://oss.sonatype.org/content/repositories/releases</url>
- <name>Sonatype Release</name>
- </repository>
- <repository>
- <id>Gson</id>
- <name>Gson maven repository</name>
- <url>http://google-gson.googlecode.com/svn/mavenrepo</url>
- </repository>
- <repository>
- <id>JBoss</id>
- <name>JBoss maven repository</name>
- <url>http://repository.jboss.org/nexus/content/groups/public/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <id>jetty-with-staging</id>
+ <name>Jetty with staging</name>
+ <url>https://oss.sonatype.org/content/groups/jetty-with-staging</url>
+ <layout>default</layout>
</repository>
</repositories>
</project>
View
10 lib/net/sourceforge/htmlunit/htmlunit/2.9-SNAPSHOT/htmlunit-2.9-SNAPSHOT.pom.lastUpdated
@@ -0,0 +1,10 @@
+#NOTE: This is an internal implementation file, its format can be changed without prior notice.
+#Sun Feb 13 08:46:44 AST 2011
+http\://google-gson.googlecode.com/svn/mavenrepo/.lastUpdated=1297601201638
+http\://google-gson.googlecode.com/svn/mavenrepo/.error=
+http\://oss.sonatype.org/content/repositories/releases/.error=
+http\://oss.sonatype.org/content/repositories/releases/.lastUpdated=1297601201965
+file\:///Users/ahellesoy/scm/dnode-java/dnode/lib/.error=
+http\://repository.jboss.org/nexus/content/groups/public/.error=
+http\://repository.jboss.org/nexus/content/groups/public/.lastUpdated=1297601204817
+file\:///Users/ahellesoy/scm/dnode-java/dnode/lib/.lastUpdated=1297601200181
View
4 ...ket/2.9-SNAPSHOT/maven-metadata-local.xml → ...nit/2.9-SNAPSHOT/maven-metadata-local.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>net.sourceforge.htmlunit</groupId>
- <artifactId>htmlunit-websocket</artifactId>
+ <artifactId>htmlunit</artifactId>
<version>2.9-SNAPSHOT</version>
<versioning>
<snapshot>
<localCopy>true</localCopy>
</snapshot>
- <lastUpdated>20110208203837</lastUpdated>
+ <lastUpdated>20110213125036</lastUpdated>
</versioning>
</metadata>
View
10 lib/net/sourceforge/htmlunit/htmlunit/2.9-SNAPSHOT/resolver-status.properties
@@ -0,0 +1,10 @@
+#NOTE: This is an internal implementation file, its format can be changed without prior notice.
+#Sun Feb 13 08:46:40 AST 2011
+maven-metadata-Sonatype.xml.lastUpdated=1297601199659
+maven-metadata-Local.xml.error=
+maven-metadata-Local.xml.lastUpdated=1297601198868
+maven-metadata-GSon.xml.error=
+maven-metadata-Sonatype.xml.error=
+maven-metadata-GSon.xml.lastUpdated=1297601199758
+maven-metadata-JBoss.xml.lastUpdated=1297601200176
+maven-metadata-JBoss.xml.error=
View
4 ...mlunit-websocket/maven-metadata-local.xml → ...tmlunit/htmlunit/maven-metadata-local.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>net.sourceforge.htmlunit</groupId>
- <artifactId>htmlunit-websocket</artifactId>
+ <artifactId>htmlunit</artifactId>
<versioning>
<versions>
<version>2.9-SNAPSHOT</version>
</versions>
- <lastUpdated>20110208203837</lastUpdated>
+ <lastUpdated>20110213125036</lastUpdated>
</versioning>
</metadata>
View
20 pom.xml
@@ -27,7 +27,6 @@
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<version>3.2.3.Final</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -37,13 +36,26 @@
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
- <artifactId>htmlunit-websocket</artifactId>
+ <artifactId>htmlunit</artifactId>
<version>2.9-SNAPSHOT</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<repositories>
<repository>
+ <id>Local</id>
+ <url>file://${basedir}/lib/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
<id>GSon</id>
<url>http://google-gson.googlecode.com/svn/mavenrepo/</url>
</repository>
@@ -55,10 +67,6 @@
<id>JBoss</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
- <repository>
- <id>Local</id>
- <url>file://${project.dir}/lib/</url>
- </repository>
</repositories>
<build>
<plugins>
View
1 src/main/java/dnode/webbit/WebbitConnection.java
@@ -9,7 +9,6 @@
public class WebbitConnection implements Connection {
private final WebSocketConnection webSocketConnection;
- private final LinkedList<String> incoming = new LinkedList<String>();
public WebbitConnection(WebSocketConnection webSocketConnection) {
if (webSocketConnection == null) {
View
1 src/test/java/dnode/DNodeTest.java
@@ -17,7 +17,6 @@
public class DNodeTest {
private DNode dNode;
private final Server server = new NettyServer(6060);
-;
public class Mooer {
private final int moo;
View
48 src/test/java/dnode/webbit/WebbitIntegrationTest.java
@@ -0,0 +1,48 @@
+package dnode.webbit;
+
+import com.gargoylesoftware.htmlunit.AlertHandler;
+import com.gargoylesoftware.htmlunit.BrowserVersion;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import dnode.Callback;
+import dnode.DNode;
+import org.junit.Ignore;
+import org.junit.Test;
+import webbit.WebServer;
+import webbit.handler.EmbeddedResourceHandler;
+import webbit.netty.NettyWebServer;
+
+import java.io.IOException;
+
+import static java.lang.Thread.sleep;
+import static java.util.concurrent.Executors.newFixedThreadPool;
+
+public class WebbitIntegrationTest {
+ public static class Cat {
+ public void cat(Callback cb) {
+ System.out.println("cb = " + cb);
+ cb.call("GROWL");
+ }
+ }
+
+ @Test
+ public void should_work_with_browser() throws IOException, InterruptedException {
+ WebServer server = new NettyWebServer(6061);
+ new DNode(new Cat()).listen(new WebbitServer(server));
+ server.add("/.*", new EmbeddedResourceHandler("dnode/js", newFixedThreadPool(4)));
+ server.start();
+
+ WebClient client = new WebClient(BrowserVersion.INTERNET_EXPLORER_8);
+ client.setAlertHandler(new AlertHandler(){
+ @Override
+ public void handleAlert(Page page, String message) {
+ System.out.println("alert = " + message);
+ }
+ });
+ HtmlPage page = client.getPage("http://localhost:6061/");
+
+ sleep(5000);
+ // Expected to see GROWL in stdout at least, but not happening...
+ }
+}
View
4 src/test/resources/dnode/js/index.html
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html>
<head>
-<script src="/dnode.js" type="text/javascript"></script>
-<script type="text/javascript">
+<script src="/dnode.js"></script>
+<script>
window.onload = function () {
DNode.connect(function (remote) {
remote.cat(function (says) {

0 comments on commit 3933c4a

Please sign in to comment.
Something went wrong with that request. Please try again.