From 8c5151afb003a8369bb145e20985232a2a631569 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 28 Apr 2014 10:15:23 +0200 Subject: [PATCH] Little test fixes. --- test/abstract_server.js | 63 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/test/abstract_server.js b/test/abstract_server.js index 125dd4a..2b04838 100644 --- a/test/abstract_server.js +++ b/test/abstract_server.js @@ -353,7 +353,7 @@ module.exports = function(moscaSettings, createConnection) { }, keepalive * 1000 / 2); }); - fastForward(100, 4000); + fastForward(50, 3000); }); }); @@ -1556,6 +1556,7 @@ module.exports = function(moscaSettings, createConnection) { client.on("publish", function(packet) { expect(packet.topic).to.be.eql("hello"); expect(packet.payload).to.be.eql("world"); + expect(packet.qos).to.be.eql(1); client.disconnect(); }); }); @@ -1672,6 +1673,66 @@ module.exports = function(moscaSettings, createConnection) { ], done); }); + it("should support offline messaging", function(done) { + var opts = buildOpts(); + + opts.clientId = "mosca-unclean-clients-test2"; + opts.clean = false; + opts.keepalive = 0; + + async.series([ + + function(cb) { + buildAndConnect(cb, opts, function(client) { + var subscriptions = [{ + topic: "hello", + qos: 1 + }]; + + client.subscribe({ + subscriptions: subscriptions, + messageId: 42 + }); + + client.on("suback", function() { + client.disconnect(); + }); + }); + }, + + function(cb) { + buildClient(cb, function(client) { + client.connect(buildOpts()); + + client.publish({ + topic: "hello", + qos: 1, + payload: "world", + messageId: 42 + }); + + client.on("puback", function(packet) { + client.disconnect(); + }); + }); + }, + + function(cb) { + buildAndConnect(cb, opts, function(client) { + + client.on("publish", function(packet) { + client.puback({ messageId: packet.messageId }); + client.disconnect(); + + expect(packet.topic).to.eql("hello"); + expect(packet.payload).to.eql("world"); + expect(packet.qos).to.eql(1); + }); + }); + } + ], done); + }); + describe("pattern matching", function() { var buildTest = function(subscribed, published, expected) {