activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject [1/2] git commit: add a test cast to shows stomp websocket utf-8 handing failing
Date Tue, 29 Apr 2014 14:02:51 GMT
Repository: activemq-apollo
Updated Branches:
  refs/heads/trunk 3ab49df79 -> 1e3eadff4


add a test cast to shows stomp websocket utf-8 handing failing


Project: http://git-wip-us.apache.org/repos/asf/activemq-apollo/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-apollo/commit/35c3c798
Tree: http://git-wip-us.apache.org/repos/asf/activemq-apollo/tree/35c3c798
Diff: http://git-wip-us.apache.org/repos/asf/activemq-apollo/diff/35c3c798

Branch: refs/heads/trunk
Commit: 35c3c798e6eb346238bbc5490b378df3a6df911e
Parents: 3ab49df
Author: leiqin <leiqin2010@gmail.com>
Authored: Sun Apr 27 18:32:26 2014 +0800
Committer: leiqin <leiqin2010@gmail.com>
Committed: Sun Apr 27 18:32:26 2014 +0800

----------------------------------------------------------------------
 .../apollo/stomp/test/websocket-utf-8.html      | 60 +++++++++++++++++
 .../apollo/stomp/test/StompWebSocketTests.scala | 68 ++++++++++++++++++++
 .../apollo/stomp/test/WebSocketSupport.scala    |  2 +
 3 files changed, 130 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/35c3c798/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket-utf-8.html
----------------------------------------------------------------------
diff --git a/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket-utf-8.html
b/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket-utf-8.html
new file mode 100644
index 0000000..fdafede
--- /dev/null
+++ b/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket-utf-8.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>Chat Example Using STOMP Over WebSockets</title>
+    <!--[if lt IE 9]>
+    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+    <![endif]-->
+    <script src='jquery.js'></script>
+    <script src='stomp.js'></script>
+    <script>//<![CDATA[
+    String.prototype.repeat = function( num ) {
+        return new Array( num + 1 ).join( this );
+    }
+
+    $(document).ready(function() {
+        if(window.WebSocket) {
+            var url = "ws://localhost:61623";
+            if(window.location.hash) {
+                url = window.location.hash.substring(1);
+            }
+            var login = "admin";
+            var passcode = "password";
+            destination = "/queue/websocket";
+
+            client = Stomp.client(url);
+
+            // the client is notified when it is connected to the server.
+            client.connect(login, passcode, function(frame) {
+                client.send(destination, null, "你好");
+                $("#status").html("Sent");
+
+            });
+        } else {
+            $("#status").html("No WebSockets");
+        }
+    });
+    //]]></script>
+</head>
+<body>
+<div id="status">Message not sent</div>
+<div id="received"></div>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/35c3c798/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala
----------------------------------------------------------------------
diff --git a/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala
b/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala
index 4d91e88..04e0da5 100644
--- a/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala
+++ b/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala
@@ -127,6 +127,7 @@ object StompWebSocketTests {
 
         driver.get(url + "#" + protocol + "://127.0.0.1:" + ws_port);
 
+        Thread.sleep(100)
         val web_status = driver.findElement(By.id("status"));
 
         while ("Message not sent" == web_status.getText) {
@@ -144,6 +145,73 @@ object StompWebSocketTests {
 
       }
     }
+
+    // broker sends client utf-8 message..
+    for (protocol <- Array("ws", "wss")) {
+      test("websockets utf-8 messages to client: " + protocol) {
+
+        val url = "http://localhost:" + jetty_port + "/websocket.html"
+        val ws_port: Int = connector_port(protocol).get
+
+        System.out.println("url: " + url)
+        driver.get(url + "#" + protocol + "://127.0.0.1:" + ws_port);
+        val web_status = driver.findElement(By.id("status"));
+        val web_received = driver.findElement(By.id("received"));
+
+        while ("Loading" == web_status.getText) {
+          Thread.sleep(100)
+        }
+
+        // Skip test if browser does not support websockets..
+        if (web_status.getText != "No WebSockets") {
+
+          // Wait for it to get connected..
+          within(2, SECONDS) {
+            web_status.getText should be("Connected")
+          }
+
+          // Send a message via normal TCP stomp..
+          connect("1.1")
+          async_send("/queue/websocket", "你好")
+          within(2, SECONDS) {
+            // it should get received by the websocket client.
+            web_received.getText should be("你好")
+          }
+
+        }
+
+      }
+    }
+
+    // client sends broker utf-8 message..
+    for(protocol <- Array( "ws")){
+      test("websockets utf-8 messages from client: "  +protocol){
+        val url = "http://localhost:" + jetty_port + "/websocket-utf-8.html"
+        val ws_port: Int = connector_port(protocol).get
+
+        System.out.println("url: " + url)
+
+        driver.get(url + "#" + protocol + "://127.0.0.1:" + ws_port);
+
+        Thread.sleep(100)
+        val web_status = driver.findElement(By.id("status"));
+
+        while ("Message not sent" == web_status.getText) {
+          Thread.sleep(100)
+        }
+
+        if(web_status != "No WebSockets"){
+          connect("1.1")
+          subscribe("0", "/queue/websocket")
+
+          within(5, SECONDS){
+            assert_received("你好", "0")
+          }
+        }
+
+      }
+    }
+
   }
 
 }

http://git-wip-us.apache.org/repos/asf/activemq-apollo/blob/35c3c798/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebSocketSupport.scala
----------------------------------------------------------------------
diff --git a/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebSocketSupport.scala
b/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebSocketSupport.scala
index 3800471..7328a2a 100644
--- a/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebSocketSupport.scala
+++ b/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebSocketSupport.scala
@@ -51,6 +51,8 @@ abstract class WebSocketSupport extends StompTestSupport with WebDriverTrait{
     file.copy_to(test_data_dir / "websocket.html")
     file = new File(getClass.getResource("websocket-large.html").getPath)
     file.copy_to(test_data_dir / "websocket-large.html")
+    file = new File(getClass.getResource("websocket-utf-8.html").getPath)
+    file.copy_to(test_data_dir / "websocket-utf-8.html")
     new File(file.getParentFile, "../../../../../../../../../apollo-distro/src/main/release/examples/stomp/websocket/js/jquery-1.7.2.min.js").getCanonicalFile.copy_to(test_data_dir
/ "jquery.js")
     new File(file.getParentFile, "../../../../../../../../../apollo-distro/src/main/release/examples/stomp/websocket/js/stomp.js").getCanonicalFile.copy_to(test_data_dir
/ "stomp.js")
 


Mime
View raw message