camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmoulli...@apache.org
Subject svn commit: r1240087 - in /camel/trunk/components/camel-websocket: pom.xml src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRoute2Test.java src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java
Date Fri, 03 Feb 2012 11:28:14 GMT
Author: cmoulliard
Date: Fri Feb  3 11:28:13 2012
New Revision: 1240087

URL: http://svn.apache.org/viewvc?rev=1240087&view=rev
Log:
Add a first camel unit test for websocket

Added:
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRoute2Test.java
Modified:
    camel/trunk/components/camel-websocket/pom.xml
    camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java

Modified: camel/trunk/components/camel-websocket/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/pom.xml?rev=1240087&r1=1240086&r2=1240087&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/pom.xml (original)
+++ camel/trunk/components/camel-websocket/pom.xml Fri Feb  3 11:28:13 2012
@@ -89,4 +89,11 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
+
+    <repositories>
+        <repository>
+            <id>cubeindia</id>
+            <url>http://m2.cubeia.com/nexus/content/repositories/thirdparty/</url>
+        </repository>
+    </repositories>
 </project>
\ No newline at end of file

Added: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRoute2Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRoute2Test.java?rev=1240087&view=auto
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRoute2Test.java
(added)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRoute2Test.java
Fri Feb  3 11:28:13 2012
@@ -0,0 +1,82 @@
+package org.apache.camel.component.websocket;
+
+import de.roderick.weberknecht.WebSocketConnection;
+import de.roderick.weberknecht.WebSocketEventHandler;
+import de.roderick.weberknecht.WebSocketException;
+import de.roderick.weberknecht.WebSocketMessage;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.CamelTestSupport;
+import org.junit.Test;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class WebsocketClientCamelRoute2Test extends CamelTestSupport {
+
+    private static URI uriWS;
+    private static WebSocketConnection webSocketConnection;
+
+    @Test
+    public void testWSHttpCall() throws WebSocketException {
+
+        try {
+            uriWS = new URI("ws://127.0.0.1:9292/test");
+            WebSocketConnection webSocketConnection = new WebSocketConnection(uriWS);
+
+            // Register Event Handlers
+            webSocketConnection.setEventHandler(new WebSocketEventHandler() {
+                public void onOpen() {
+                    System.out.println("--open");
+                }
+
+                public void onMessage(WebSocketMessage message) {
+                    System.out.println("--received message: " + message.getText());
+                }
+
+                public void onClose() {
+                    System.out.println("--close");
+                }
+            });
+
+            // Establish WebSocket Connection
+            webSocketConnection.connect();
+            System.out.println(">>> Connection established.");
+
+                        // Send Data
+            webSocketConnection.send("Hello from WS Client");
+
+
+        } catch (WebSocketException ex) {
+            ex.printStackTrace();
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("websocket://test")
+                    .setExchangePattern(ExchangePattern.InOut)
+                    .log(">>> Message received from WebSocket Client : ${body}")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            String response = ">> welcome on board";
+                            exchange.getOut().setBody(response);
+                            exchange.getIn().setBody(response);
+                        }
+                    });
+
+            }
+        };
+    }
+
+
+}

Modified: camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java?rev=1240087&r1=1240086&r2=1240087&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java
(original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRouteTest.java
Fri Feb  3 11:28:13 2012
@@ -4,7 +4,6 @@ import de.roderick.weberknecht.WebSocket
 import de.roderick.weberknecht.WebSocketEventHandler;
 import de.roderick.weberknecht.WebSocketException;
 import de.roderick.weberknecht.WebSocketMessage;
-import org.apache.camel.ExchangePattern;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.CamelTestSupport;
 import org.junit.Test;
@@ -43,7 +42,7 @@ public class WebsocketClientCamelRouteTe
             webSocketConnection.connect();
             System.out.println(">>> Connection established.");
 
-                        // Send Data
+            // Send Data
             webSocketConnection.send("Hello from WS Client");
 
 
@@ -61,16 +60,7 @@ public class WebsocketClientCamelRouteTe
         return new RouteBuilder() {
             public void configure() {
                 from("websocket://test")
-                    .setExchangePattern(ExchangePattern.InOut)
                     .log(">>> Message received from WebSocket Client : ${body}")
-/*                    .process(new Processor() {
-                        @Override
-                        public void process(Exchange exchange) throws Exception {
-                           String response = ">> welcome on board";
-                            exchange.getOut().setBody(response);
-                            exchange.getIn().setBody(response);
-                        }
-                    });*/
                     .loop(10)
                         .setBody().constant(">> Welcome on board !")
                         .to("websocket://test");



Mime
View raw message