camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1243315 - in /camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket: WebsocketClientCamelRoute2Test.java WebsocketClientCamelRouteTest.java
Date Sun, 12 Feb 2012 20:23:28 GMT
Author: bvahdat
Date: Sun Feb 12 20:23:28 2012
New Revision: 1243315

URL: http://svn.apache.org/viewvc?rev=1243315&view=rev
Log:
Polished and more assertion on the expected.

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

Modified: 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=1243315&r1=1243314&r2=1243315&view=diff
==============================================================================
--- camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRoute2Test.java
(original)
+++ camel/trunk/components/camel-websocket/src/test/java/org/apache/camel/component/websocket/WebsocketClientCamelRoute2Test.java
Sun Feb 12 20:23:28 2012
@@ -30,12 +30,11 @@ import org.junit.Test;
 
 public class WebsocketClientCamelRoute2Test extends CamelTestSupport {
 
-    private static URI uriWS;
-
     @Test
     public void testWSHttpCall() throws Exception {
-        uriWS = new URI("ws://127.0.0.1:9292/test");
-        WebSocketConnection webSocketConnection = new WebSocketConnection(uriWS);
+        getMockEndpoint("mock:websocket").expectedBodiesReceived(">> Welcome on board!");
+
+        WebSocketConnection webSocketConnection = new WebSocketConnection(new URI("ws://127.0.0.1:9292/test"));
 
         // Register Event Handlers
         webSocketConnection.setEventHandler(new WebSocketEventHandler() {
@@ -58,6 +57,11 @@ public class WebsocketClientCamelRoute2T
 
         // Send Data
         webSocketConnection.send("Hello from WS Client");
+
+        // Close WebSocket Connection
+        webSocketConnection.close();
+
+        getMockEndpoint("mock:websocket").assertIsSatisfied();
     }
 
     @Override
@@ -70,14 +74,11 @@ public class WebsocketClientCamelRoute2T
                     .process(new Processor() {
                         @Override
                         public void process(Exchange exchange) throws Exception {
-                            String response = ">> welcome on board";
-                            exchange.getOut().setBody(response);
-                            exchange.getIn().setBody(response);
+                            exchange.getIn().setBody(">> Welcome on board!");
                         }
-                    });
+                    })
+                    .to("mock:websocket");
             }
         };
     }
-
-
 }

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=1243315&r1=1243314&r2=1243315&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
Sun Feb 12 20:23:28 2012
@@ -27,13 +27,9 @@ import org.junit.Test;
 
 public class WebsocketClientCamelRouteTest extends CamelTestSupport {
 
-    private static URI uriWS;
-
     @Test
     public void testWSHttpCall() throws Exception {
-
-        uriWS = new URI("ws://127.0.0.1:9292/test");
-        WebSocketConnection webSocketConnection = new WebSocketConnection(uriWS);
+        WebSocketConnection webSocketConnection = new WebSocketConnection(new URI("ws://127.0.0.1:9292/test"));
 
         // Register Event Handlers
         webSocketConnection.setEventHandler(new WebSocketEventHandler() {
@@ -56,6 +52,9 @@ public class WebsocketClientCamelRouteTe
 
         // Send Data
         webSocketConnection.send("Hello from WS Client");
+
+        // Close WebSocket Connection
+        webSocketConnection.close();
     }
 
     @Override
@@ -65,10 +64,9 @@ public class WebsocketClientCamelRouteTe
                 from("websocket://test")
                     .log(">>> Message received from WebSocket Client : ${body}")
                     .loop(10)
-                        .setBody().constant(">> Welcome on board !")
+                        .setBody().constant(">> Welcome on board!")
                         .to("websocket://test");
             }
         };
     }
-
 }



Mime
View raw message