Skip to content

Commit

Permalink
activate msgpack tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oberstet committed May 19, 2019
1 parent 87ade2a commit cfa978a
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 51 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ test_pubsub_multiple_matching_subs:

test_binary:
nodeunit test/test_binary.js -t testBinaryCBOR
nodeunit test/test_binary.js -t testBinaryMsgPack
4 changes: 1 addition & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ exports.testMsgpackSerialization = serialization_msgpack.testMsgpackSerializatio
exports.testCBORSerialization = serialization_cbor.testCBORSerialization;

exports.testBinaryCBOR = binary.testBinaryCBOR;

// FIXME:
// exports.testBinaryMsgPack = binary.testBinaryMsgPack;
exports.testBinaryMsgPack = binary.testBinaryMsgPack;
// exports.testBinaryJSON = binary.testBinaryJSON;

exports.testRawSocketTransport = rawsocket_transport.testRawSocketTransport;
Expand Down
69 changes: 40 additions & 29 deletions test/test_binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ var testutil = require('./testutil.js');
var seed = require('random-bytes-seed')
var randomBytes = seed('a seed')

/*
AutobahnJS supports use of native binary values in application payload args/kwargs
of WAMP calls or events. Use the following JavaScript types:
* browsers: Uint8Array (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
* node: Buffer (https://nodejs.org/api/buffer.html)
*/

function run_test (test, ser) {

Expand All @@ -33,7 +40,7 @@ function run_test (test, ser) {

connection.onopen = function (session) {

test.log('Connected');
test.log('Connected: ' + session._socket.info.protocol);

function echo(args) {
return args[0];
Expand Down Expand Up @@ -93,35 +100,39 @@ function run_test (test, ser) {
));
}

for (var i = 0; i < vals1.length; ++i) {

pl2.push(session.call('any.echo', [vals1[i]]).then(
function (res) {
if (Buffer.isBuffer(res)) {
test.log("Result [any.echo]: " + res.toString('hex'));
} else if (res && res.constructor == Object) {
test.log("Result [any.echo]:");
for (var key in res) {
if (res[key] && Buffer.isBuffer(res[key])) {
test.log(" " + key + ", " + res[key].toString('hex'));
} else {
test.log(" " + key + ", " + res[key]);
autobahn.when.all(pl2).then(function () {
var pl3 = [];

for (var i = 0; i < vals1.length; ++i) {

pl3.push(session.call('any.echo', [vals1[i]]).then(
function (res) {
if (Buffer.isBuffer(res)) {
test.log("Result [any.echo]: " + res.toString('hex'));
} else if (res && res.constructor == Object) {
test.log("Result [any.echo]:");
for (var key in res) {
if (res[key] && Buffer.isBuffer(res[key])) {
test.log(" " + key + ", " + res[key].toString('hex'));
} else {
test.log(" " + key + ", " + res[key]);
}
}
}
} else {
test.log("Result [any.echo]: " + res);
}
},
function (err) {
test.log("Error [any.echo]:", err.error, err.args, err.kwargs);
}
));
}

autobahn.when.all(pl2).then(function () {
test.log("All finished.");
connection.close();
done.resolve();
} else {
test.log("Result [any.echo]: " + res);
}
},
function (err) {
test.log("Error [any.echo]:", err.error, err.args, err.kwargs);
}
));
}

autobahn.when.all(pl3).then(function () {
test.log("All finished.");
connection.close();
done.resolve();
});
});
},
function () {
Expand Down
38 changes: 19 additions & 19 deletions test/test_binary_cbor.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
0 "Connected"
0 "Connected: wamp.2.cbor"
1 "All registered."
2 "Serializer ID: cbor"
3 "Result [any.echo]: 1.7"
4 "Result [any.echo]: hello"
5 "Result [any.echo]: 1,2,-3"
6 "Result [any.echo]:"
3 "Result [com.myapp.echo]: 1.7"
4 "Result [com.myapp.echo]: hello"
5 "Result [com.myapp.echo]: 1,2,-3"
6 "Result [com.myapp.echo]:"
7 " a, 5"
8 " b, hello2"
9 " c, 1,2,3"
10 "Result [any.echo]: -9007199254740991,9007199254740991"
11 "Result [any.echo]: null"
12 "Result [any.echo]: 0001020304050607"
13 "Result [any.echo]: 8f44d509e0492acec4fc109a030a5c751f063fb743cc388f0ed722bacc3bc66c"
14 "Result [any.echo]:"
10 "Result [com.myapp.echo]: -9007199254740991,9007199254740991"
11 "Result [com.myapp.echo]: null"
12 "Result [com.myapp.echo]: 0001020304050607"
13 "Result [com.myapp.echo]: 8f44d509e0492acec4fc109a030a5c751f063fb743cc388f0ed722bacc3bc66c"
14 "Result [com.myapp.echo]:"
15 " a, 5"
16 " b, hello2"
17 " c, 035e7711c8da2e9434aab5039dc3d72046dee4e57af0e957e948fbbad15e48f8"
18 "Result [com.myapp.echo]: 1.7"
19 "Result [com.myapp.echo]: hello"
20 "Result [com.myapp.echo]: 1,2,-3"
21 "Result [com.myapp.echo]:"
18 "Result [any.echo]: 1.7"
19 "Result [any.echo]: hello"
20 "Result [any.echo]: 1,2,-3"
21 "Result [any.echo]:"
22 " a, 5"
23 " b, hello2"
24 " c, 1,2,3"
25 "Result [com.myapp.echo]: -9007199254740991,9007199254740991"
26 "Result [com.myapp.echo]: null"
27 "Result [com.myapp.echo]: 0001020304050607"
28 "Result [com.myapp.echo]: 8f44d509e0492acec4fc109a030a5c751f063fb743cc388f0ed722bacc3bc66c"
29 "Result [com.myapp.echo]:"
25 "Result [any.echo]: -9007199254740991,9007199254740991"
26 "Result [any.echo]: null"
27 "Result [any.echo]: 0001020304050607"
28 "Result [any.echo]: 8f44d509e0492acec4fc109a030a5c751f063fb743cc388f0ed722bacc3bc66c"
29 "Result [any.echo]:"
30 " a, 5"
31 " b, hello2"
32 " c, 035e7711c8da2e9434aab5039dc3d72046dee4e57af0e957e948fbbad15e48f8"
Expand Down
34 changes: 34 additions & 0 deletions test/test_binary_msgpack.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
0 "Connected: wamp.2.msgpack"
1 "All registered."
2 "Serializer ID: msgpack"
3 "Result [com.myapp.echo]: 1.7"
4 "Result [com.myapp.echo]: hello"
5 "Result [com.myapp.echo]: 1,2,-3"
6 "Result [com.myapp.echo]:"
7 " a, 5"
8 " b, hello2"
9 " c, 1,2,3"
10 "Result [com.myapp.echo]: -9007199254740991,9007199254740991"
11 "Result [com.myapp.echo]: null"
12 "Result [com.myapp.echo]: 0001020304050607"
13 "Result [com.myapp.echo]: 8f44d509e0492acec4fc109a030a5c751f063fb743cc388f0ed722bacc3bc66c"
14 "Result [com.myapp.echo]:"
15 " a, 5"
16 " b, hello2"
17 " c, 035e7711c8da2e9434aab5039dc3d72046dee4e57af0e957e948fbbad15e48f8"
18 "Result [any.echo]: 1.7"
19 "Result [any.echo]: hello"
20 "Result [any.echo]: 1,2,-3"
21 "Result [any.echo]:"
22 " a, 5"
23 " b, hello2"
24 " c, 1,2,3"
25 "Result [any.echo]: -9007199254740991,9007199254740991"
26 "Result [any.echo]: null"
27 "Result [any.echo]: 0001020304050607"
28 "Result [any.echo]: 8f44d509e0492acec4fc109a030a5c751f063fb743cc388f0ed722bacc3bc66c"
29 "Result [any.echo]:"
30 " a, 5"
31 " b, hello2"
32 " c, 035e7711c8da2e9434aab5039dc3d72046dee4e57af0e957e948fbbad15e48f8"
33 "All finished."

0 comments on commit cfa978a

Please sign in to comment.