Skip to content

Commit

Permalink
fix(SenderLink): use defaultSubject from policy, added test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Aug 10, 2015
1 parent 0cfd687 commit 3b676a2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/sender_link.js
Expand Up @@ -66,7 +66,7 @@ SenderLink.prototype.send = function(msg, options) {
if (!!this.policy.defaultSubject) {
if (!options.properties) options.properties = {};
if (!options.properties.subject)
options.properties.subject = this.defaultSubject;
options.properties.subject = this.policy.defaultSubject;
}

var self = this;
Expand Down
2 changes: 1 addition & 1 deletion test/integration/qpid/receiver_link.test.js
Expand Up @@ -26,7 +26,7 @@ describe('ReceiverLink', function() {
return Promise.all([
test.client.createReceiver('amq.topic/not-news'),
test.client.createReceiver('amq.topic/news'),
test.client.createSender('amq.topic/news')
test.client.createSender('amq.topic')
]);
})
.spread(function(receiverWithoutSubject, receiverWithSubject, sender) {
Expand Down
46 changes: 46 additions & 0 deletions test/integration/qpid/sender_link.test.js
@@ -0,0 +1,46 @@
'use strict';
var AMQPClient = require('../../..').Client,
c = require('../../../').Constants,
Promise = require('bluebird'),
config = require('./config'),
expect = require('chai').expect;

var test = {};
describe('QPID', function() {

describe('SenderLink', function() {
beforeEach(function() {
if (!!test.client) test.client = undefined;
test.client = new AMQPClient();
});

afterEach(function() {
return test.client.disconnect().then(function() {
test.client = undefined;
});
});

it('should allow the definition of a default subject', function(done) {
return test.client.connect(config.address)
.then(function() {
return Promise.all([
test.client.createReceiver('amq.topic/not-news'),
test.client.createReceiver('amq.topic/news'),
test.client.createSender('amq.topic/news')
]);
})
.spread(function(receiverWithoutSubject, receiverWithSubject, sender) {
receiverWithoutSubject.on('message', function(message) {
expect(message).to.not.exist;
});

receiverWithSubject.on('message', function(message) {
done();
});

return sender.send('test message');
});
});

});
});

0 comments on commit 3b676a2

Please sign in to comment.