[Pkg-javascript-commits] [sockjs-client] 05/434: Test batched messages

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:46:57 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 4e192a78e0b48c8e879c13fbb073800fc5f17447
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Fri Jul 22 16:11:21 2011 +0100

    Test batched messages
---
 tests-src/test-factory.coffee | 38 ++++++++++++++++++++++++++++++++++++++
 tests-src/test-run.coffee     |  5 +++--
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/tests-src/test-factory.coffee b/tests-src/test-factory.coffee
index f5e3ab3..f22bbd6 100644
--- a/tests-src/test-factory.coffee
+++ b/tests-src/test-factory.coffee
@@ -83,3 +83,41 @@ factor_echo_large_message = (protocol) ->
         Array(4096*8).join('x'),
     ]
     return echo_factory_factory(protocol, messages, 'large_message')
+
+
+batch_factory_factory = (protocol, messages, name) ->
+    return ->
+        expect(3 + messages.length)
+        r = new SockJS(test_server_url + '/echo', [protocol])
+        ok(r)
+        counter = 0
+        r.onopen = (e) ->
+            if debug
+                log(name+'_'+protocol+'_open', e)
+            ok(true)
+            for msg in messages
+                r.send(msg)
+        r.onmessage = (e) ->
+            if debug
+                log(name+'_'+protocol+'_msg', e.data + ' ' + messages[counter])
+            equals(e.data, messages[counter])
+            counter += 1
+            if counter is messages.length
+                r.close()
+        r.onclose = (e) ->
+            if debug
+                log(name+'_'+protocol+'_close', e)
+            ok(true)
+            start()
+
+factor_batch_large = (protocol) ->
+    messages = [
+        Array(Math.pow(2,1)).join('x'),
+        Array(Math.pow(2,2)).join('x'),
+        Array(Math.pow(2,4)).join('x'),
+        Array(Math.pow(2,8)).join('x'),
+        Array(Math.pow(2,16)).join('x'),
+        Array(Math.pow(2,17)).join('x'),
+        Array(Math.pow(2,18)).join('x'),
+    ]
+    return batch_factory_factory(protocol, messages, 'batch_large')
diff --git a/tests-src/test-run.coffee b/tests-src/test-run.coffee
index 012af09..456a45c 100644
--- a/tests-src/test-run.coffee
+++ b/tests-src/test-run.coffee
@@ -2,13 +2,14 @@
 test_protocol = (protocol) ->
     module(protocol)
     if not SockJS[protocol].enabled()
-        test "skipping...", ->
-                log(name + " skipping protocol " + protocol)
+        test "[unsupported]", ->
+                log('Unsupported protocol: "' + protocol + '"')
     else
         asyncTest("echo", factor_echo_basic(protocol))
         asyncTest("unicode", factor_echo_unicode(protocol))
         asyncTest("special_chars", factor_echo_special_chars(protocol))
         asyncTest("large_message", factor_echo_large_message(protocol))
+        asyncTest("batch_large", factor_batch_large(protocol))
 
 
 for protocol in ['ws', 'jsonp']

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list