New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mqlight-dev

Package Overview
Dependencies
Maintainers
5
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqlight-dev - npm Package Compare versions

Comparing version 1.0.2014111002 to 1.0.2015021700-beta

state-machine.gif

5

bin/mqlight-debug.js
#!/usr/bin/env node
/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/bin/mqlight-debug.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/bin/mqlight-debug.js
*/
/*

@@ -5,0 +8,0 @@ * <copyright

31

mqlight-log.js

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/mqlight-log.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/mqlight-log.js
*/
/*

@@ -59,3 +62,5 @@ * <copyright

var write = function(lvl, prefix, args) {
npmlog.heading = moment().format('HH:mm:ss.SSS') + ' [' + process.pid + ']';
if (npmlog.levels[npmlog.level] <= npmlog.levels[lvl]) {
npmlog.heading = moment().format('HH:mm:ss.SSS') + ' [' + process.pid + ']';
}
npmlog.log.apply(this, arguments);

@@ -101,6 +106,6 @@ };

if ('ffdcSequence' in options) {
write(lvl, clientId, '| FDCSequenceNumber :-', options.ffdcSequence++);
write(lvl, clientId, '| FFDCSequenceNumber:-', options.ffdcSequence++);
}
if (potentialUnwinds !== 0) {
write(lvl, clientId, '| potentialUnwinds :-', potentialUnwinds);
write(lvl, clientId, '| potentialUnwinds :-', potentialUnwinds);
}

@@ -519,2 +524,9 @@ write(lvl, clientId, HEADER_BANNER);

// In a unit testing environment we expect to get no ffdcs.
if (process.env.NODE_ENV === 'unittest') {
var err = new Error('No ffdcs expected during unit tests');
logger.throw('logger.ffdc', opts.clientId, err);
throw err;
}
logger.exit('logger.ffdc', opts.clientId, null);

@@ -533,5 +545,10 @@ };

npmlog.addLevel('all', -Infinity, styles.inverse, 'all ');
npmlog.addLevel('data_often', -Infinity, styles.green, 'data ');
npmlog.addLevel('exit_often', -Infinity, styles.yellow, 'exit ');
npmlog.addLevel('entry_often', -Infinity, styles.yellow, 'entry ');
npmlog.addLevel('proton_data', -Infinity, styles.green, 'data ');
npmlog.addLevel('proton_exit', -Infinity, styles.yellow, 'exit ');
npmlog.addLevel('proton_entry', -Infinity, styles.yellow, 'entry ');
npmlog.addLevel('proton', -Infinity, styles.yellow, 'func ');
npmlog.addLevel('data_often', 100, styles.green, 'data ');
npmlog.addLevel('exit_often', 100, styles.yellow, 'exit ');
npmlog.addLevel('entry_often', 100, styles.yellow, 'entry ');
npmlog.addLevel('often', 100, styles.yellow, 'func ');
npmlog.addLevel('raw', 200, styles.inverse, 'raw ');

@@ -538,0 +555,0 @@ npmlog.addLevel('detail', 300, styles.green, 'detail');

{
"name": "mqlight-dev",
"version": "1.0.2014111002",
"version": "1.0.2015021700-beta",
"description": "IBM MQ Light Client Module",

@@ -5,0 +5,0 @@ "main": "mqlight.js",

@@ -77,6 +77,6 @@ # node-mqlight

Creates an MQ Light client instance in `starting` state
Creates an IBM MQ Light client instance in `starting` state.
* `options` - (Object) options for the client. Properties include:
* **service**, (String | Array | Function) (required), a String containing
* **service**, (String | Array | Function) (required) a String containing
the URL for the service to connect to, or alternatively an Array

@@ -87,4 +87,4 @@ containing a list of URLs to attempt to connect to in turn, or

it is called (in the form `function(err, service)`). User names and
passwords may be embedded into the URL (e.g. `amqp://user:pass@host`).
* **id**, (String, default: `AUTO_[0-9a-f]{7}`) (optional), a unique
passwords may be embedded into the URL (for example, `amqp://user:pass@host`).
* **id**, (String, default: `AUTO_[0-9a-f]{7}`) (optional) a unique
identifier for this client. A maximum of one instance of the client (as

@@ -95,7 +95,7 @@ identified by the value of this property) can be connected the an MQ Light

This is reported, to the first client, as a `ReplacedError` being
emitted as an error event and the client transitioning into stopped state.
If the id property is not a valid client identifier (e.g. it contains a
colon, it is too long, or it contains some other forbidden character) then
the function will throw an `InvalidArgumentError`
* **user**, (String) (optional), user name for authentication.
emitted as an error event and the client transitioning into `stopped`
state. If the id property is not a valid client identifier (for example, it
contains a colon, it is too long, or it contains some other forbidden
character) then the function will throw an `InvalidArgumentError`
* **user**, (String) (optional) user name for authentication.
Alternatively, the user name may be embedded in the URL passed via the

@@ -108,12 +108,11 @@ service property. If you choose to specify a user name via this property

`InvalidArgumentError` will be thrown.
* **password**, (String) (optional), password for authentication.
Alternatively, user name may be embedded in the URL passed via the service
* **password**, (String) (optional) password for authentication.
Alternatively, a password can be embedded in the URL passed via the service
property.
* **sslTrustCertificate**, (String) (optional), SSL trust certificate to use
* **sslTrustCertificate**, (String) (optional) SSL trust certificate to use
when authentication is required for the MQ Light server. Only used when
service specifies the amqps scheme.
* **sslVerifyName**, (Boolean, default: true) (optional), whether or not to
* **sslVerifyName**, (Boolean, default: true) (optional) whether or not to
additionally check the MQ Light server's common name in the certificate
matches the actual server's DNS name. Only used when the
sslTrustCertificate option is specified.
matches the actual server's DNS name.
* `callback` - (Function) (optional) callback that is invoked (indicating

@@ -129,3 +128,3 @@ success) if the client attains `started` state, or invoked (indicating

event emitter and listeners can be registered for the following events:
`started`, `stopped`, `restarted`, `error`, `drain`, and `message`.
`started`, `stopped`, `restarted`, `error`, `drain`, `malformed` and `message`.

@@ -139,9 +138,9 @@ ### mqlight.Client.start([`callback`])

* `callback` - (Function) (optional) callback to be notified when the client
has either: transitioned into `started` state; or has entered `stopped` state
before it can transition into `started` state. The callback function will be
invoked with a `StoppedError` as its argument if the client transitions
into stopped state before it attains started state - which can happen as a
result of calling the `client.stop` method.
has either: transitioned into (or was already in) `started` state; or has
entered `stopped` state before it can transition into `started` state. The
`callback` function will be invoked with a `StoppedError` as its argument if
the client transitions into a `stopped` state before it attains a `started`
state, which can happen as a result of calling the `client.stop` method.
### mqlight.Client.stop([callback])
### mqlight.Client.stop([`callback`])

@@ -162,13 +161,13 @@ Stops the client from sending and/or receiving messages from the server. The

* `topic` - (String) the topic to which the message will be sent.
* `topic` - (String) the topic to which the message is sent.
A topic can contain any character in the Unicode character set.
* `data` - (String | Buffer | Object) the message body to be sent
* `data` - (String | Buffer | Object) the message body to be sent.
* `options` - (Object) (optional) additional options for the send operation.
Supported options are:
* **qos**, (Number) (optional) The quality of service to use when sending the
* **qos**, (Number) (optional) the quality of service to use when sending the
message. 0 is used to denote at most once (the default) and 1 is used for
at least once. If a value which is not 0 and not 1 is specified then this
method will throw a `RangeError`
* **ttl**, (Number) (optional) A time to live value for the message in
milliseconds. MQ Light will endeavour to discard, without delivering, any
* **ttl**, (Number) (optional) a time to live value for the message in
milliseconds. MQ Light will discard, without delivering, any
copy of the message that has not been delivered within its time to live

@@ -178,3 +177,3 @@ period. The default time to live is 604800000 milliseconds (7 days).

otherwise a `RangeError` will be thrown when this method is called.
* `callback` - (Function) The callback argument is optional if the qos property
* `callback` - (Function) the callback argument is optional if the qos property
of the options argument is omitted or set to 0 (at most once). If the qos

@@ -195,7 +194,7 @@ property is set to 1 (at least once) then the callback argument is required

Returns `true` if this message was sent, or is the next to be sent.
Returns `true` if this message is sent, or is the next to be sent.
Returns `false` if the message was queued in user memory, due to either a
Returns `false` if the message is queued in user memory, due to either a
backlog of messages, or because the client was not in a connected state.
When the backlog of messages is cleared, the `drain` event will be emitted.
When the backlog of messages is cleared, the `drain` event will be sent.

@@ -219,11 +218,11 @@ ### mqlight.Client.subscribe(`topicPattern`, [`share`], [`options`], [`callback`])

in the Unicode character set, with `#` representing a multilevel wildcard and
`+` a single level wildcard as described
[here](https://developer.ibm.com/messaging/mq-light/wildcard-topicpatterns/).
`+` a single level wildcard. For more information, see
[Wildcards](https://developer.ibm.com/messaging/mq-light/docs/wildcards/).
* `share` - (String) (optional) name for creating or joining a shared
destination for which messages are anycast between connected subscribers. If
omitted defaults to a private destination (e.g. messages can only be received
omitted, this defaults to a private destination (for example, messages can only be received
by a specific instance of the client).
* `options` - (Object) (optional) additional options for the subscribe
operation. Supported options are:
* **autoConfirm**, (Boolean) (optional) When set to true (the default) the
* **autoConfirm**, (Boolean) (optional) when set to true (the default) the
client will automatically confirm delivery of messages when all of the

@@ -234,17 +233,17 @@ listeners registered for the client's `message` event have returned.

the `delivery` argument of the listener registered for `message` events.
`autoConfirm` is only applicable when the `qos` property is set to 1. The
`qos` property is described later.
* **credit**, (Number) The maximum number of unconfirmed messages a client
`autoConfirm` is only applicable when the `qos` property is set to 1. (The
`qos` property is described later.)
* **credit**, (Number) the maximum number of unconfirmed messages a client
can have before the server will stop sending new messages to the client
and require that it confirms some of the outstanding message deliveries in
order to receive more messages. The default for this property is 1024. If
specified the value will be coerced to a `Number` and must be finite
and >= 0, otherwise a `RangeError` will be thrown.
* **qos**, (Number) The quality of service to use for delivering messages to
specified, the value will be coerced to a `Number` and must be finite
and greater than, or equal to 0, otherwise a `RangeError` will be thrown.
* **qos**, (Number) the quality of service to use for delivering messages to
the subscription. Valid values are: 0 to denote at most once (the
default), and 1 for at least once. A `RangeError` will be thrown for other
value.
* **ttl**, (Number) A time-to-live value, in milliseconds, that is applied
to the destination that the client is subscribed to. If specified the
value will be coerced to a `Number`, which must be finite and >= 0,
* **ttl**, (Number) a time-to-live value, in milliseconds, that is applied
to the destination that the client is subscribed to. If specified, the
value will be coerced to a `Number`, which must be finite and greater than, or equal to 0,
otherwise a `RangeError` will be thrown. This value will replace any

@@ -276,7 +275,7 @@ previous value, if the destination already exists. Time to live starts

Stops the flow of messages from a destination to this client. The client's
message callback will not longer be driven when messages arrive, that match the
message callback will not longer be driven when messages arrive that match the
pattern associated with the destination. Messages may still be stored at the
destination if it has a non-zero time to live value or is shared and is
subscribed to by other clients instances. If the client is not subscribed to a
subscription, as identified by the pattern (and optional) share arguments then
subscription, as identified by the optional pattern share arguments, then
this method will throw a `UnsubscribedError`. The pattern and share arguments

@@ -286,11 +285,11 @@ will be coerced to type `String`. The pattern argument must be present

* `topicPattern` - (String) Matched against the `topicPattern` specified on the
`mqlight.Client.subscribe` call to determine which destination the client will
* `topicPattern` - (String) matched against the `topicPattern` specified on the
`mqlight.Client.subscribe` call to determine which destination the client will be
unsubscribed from.
* `share` - (String) (optional) Matched against the `share` specified on the
`mqlight.Client.subscribe` call to determine which destination the client will
* `share` - (String) (optional) matched against the `share` specified on the
`mqlight.Client.subscribe` call to determine which destination the client will be
unsubscribed from.
* `options` - (Object) (optional) Properties that determine the behaviour of the
* `options` - (Object) (optional) properties that determine the behaviour of the
unsubscribe operation:
* **ttl**, (Number) (optional) Sets the destination's time to live as part of
* **ttl**, (Number) (optional) sets the destination's time to live as part of
the unsubscribe operation. The default (when this property is not

@@ -320,7 +319,7 @@ specified) is not to change the destination's time to live. When specified

Returns the URL of the server to which the client is currently connected
to, or undefined if not connected.
to, or `undefined` if not connected.
### mqlight.Client.state
Returns the current state of the client, which will be one of:
Returns the current state of the client, which will be one of the following states:
'starting', 'started', 'stopping', 'stopped', or 'retrying'.

@@ -334,3 +333,3 @@

* `data` - (String | Buffer | Object) the message body.
* `delivery` - (Object) additional information about why the event was emitted.
* `delivery` - (Object) additional information about why the event was sent.
Properties include:

@@ -340,4 +339,4 @@ * **message**, (Object) additional information about the message. Properties

* **topic**, (Object) the topic that the message was sent to.
* **confirmDelivery**, (Function) A method that can be used to confirm
(settle) the delivery of a at least once quality of service (qos:1)
* **confirmDelivery**, (Function) a method that can be used to confirm
(settle) the delivery of a "at least once" quality of service (qos:1)
message. This method does not expect any arguments. This property will

@@ -349,3 +348,3 @@ only be present if the message was delivered due to a subscribe call

spends at an MQ Light destination from the time to live value specified
when the message is sent to MQ Light.
when the message is sent to IBM MQ Light.
* **destination**, (Object) collects together the values that the client

@@ -362,3 +361,3 @@ specified when it subscribed to the destination from which the message

This event is emitted when a client attains `stated` state by successfully
This event is sent when a client attains the `started` state by successfully
establishing a connection to the MQ Light server. The client is ready to send

@@ -370,3 +369,3 @@ messages. The client is also ready to receive messages by subscribing to topic

This event is emitted when a client attains `stopped` state as a result of the
This event is sent when a client attains the `stopped` state as a result of the
`mqlight.Client.stop` method being invoked. In this state the client will not

@@ -378,3 +377,3 @@ receive messages, and attempting to send messages or subscribe to topic patterns

Emitted when an error is detected that prevents or interrupts a client's
Sent when an error is detected that prevents or interrupts a client's
connection to the messaging server. The client will automatically try to

@@ -390,3 +389,3 @@ reestablish connectivity unless either successful or the client is stopped by a

This event is emitted when the client has reestablished connectivity to the MQ
This event is sent when the client has reestablished connectivity to the MQ
Light server. The client will automatically re-subscribe to any destinations

@@ -399,3 +398,3 @@ that it was subscribed to prior to losing connectivity. Any send or subscribe

Emitted to indicate that the client has flushed any buffered messages to the
Sent to indicate that the client has flushed any buffered messages to the
network. This event can be used in conjunction with the value returned by the

@@ -410,8 +409,8 @@ `mqlight.Client.send` method to efficiently send messages without buffering a

This is a subtype of `Error` defined by the MQ Light client. It is considered
a programming error. The underlying cause for this error are the parameter
a programming error. The underlying causes for this error are the parameter
values passed into a method. Typically `InvalidArgumentError` is thrown
directly from a method where `TypeError` and `RangeError` do not adequately
describe the problem (e.g., you specified a client id that contains a colon).
describe the problem (for example, you specified a client id that contains a colon).
`InvalidArgumentError` may also arrive asynchronously if, for example, the
server rejects a value supplied by the client (e.g. a message time to live
server rejects a value supplied by the client (for example, a message time to live
value which exceeds the maximum value that the server will permit).

@@ -421,3 +420,3 @@

This is a subtype of `Error` defined by the MQ Light client. It is considered
This is a subtype of `Error` defined by the IBM MQ Light client. It is considered
an operational error. `NetworkError` is passed to an application if the

@@ -448,8 +447,7 @@ client cannot establish a network connection to the MQ Light server, or if an

* The client specifies an incorrect user/password combination.
* The client specifies a user / password but the server is not configured to
require a user / password.
* The client is configured to use an SSL / TLS certificate to establish the
identity of the server - but cannot.
* etc.
* The client specifies an incorrect user name and password combination.
* The client specifies a user name and password but the server is not configured to
require a user name and password.
* The client is configured to use an SSL/TLS certificate to establish the
identity of the server, but cannot.

@@ -463,3 +461,3 @@ ### Error: StoppedError

`StoppedError` is thrown by methods which require connectivity to the server
(e.g. send, subscribe) when they are invoked while the client is in stopping or
(for example, send or subscribe) when they are invoked while the client is in stopping or
stopped states. `StoppedError` is also supplied to the callbacks and supplied

@@ -485,3 +483,3 @@ to methods which require connectivity to the server, when the client

when a required parameter is omitted (the justification being that the argument
is assigned a value of undefined - which isn't the type that the client is
is assigned a value of undefined, which isn't the type that the client is
expecting).

@@ -496,2 +494,35 @@

## Client state machine
Each instance of a client (as returned from `mqlight.createClient(...)` is
backed by the following state machine:
![Diagram of a state machine](state-machine.gif)
Each of the states shown in the state machine diagram corresponds to the values
stored in the `mqlight.Client.state` property, with the exception of `retrying1`
and `retrying2` which are collapsed into a single `retrying` value. While in the
`retrying` state, the client will wait for up approximately 60 seconds (based on
an exponential backoff algorithm) before attempting to transition into a new
state.
Each line shown in the state machine diagram represents a possible way in which
the client can transition between states. The lines are labelled with
information about the transitions, which includes:
1. The function calls that can cause the transition to occur:
* `start()` corresponds to the `mqlight.Client.start` function.
* `stop()` corresponds to the `mqlight.Client.stop` function.
2. Change that occur at the network level, which can cause the transition to
occur. For example:
* `[broken]` occurs when an established network connection between the client
and the server is interrupted.
* `[connected]` occurs when the client successfully establishes a network
connection to the server.
* `[failed]` occurs when the client unsuccessfully attempts to establish a
network connection to the server.
3. Events that are emitted. Specifically:
* `<error>` indicates that an error event is sent.
* `<restarted>` indicates that a restarted event is sent.
* `<started>` indicates that a started event is sent.
* `<stopped>` indicates that a stopped event is sent.
## Samples

@@ -516,7 +547,6 @@

-c FILE, --trust-certificate=FILE
use the certificate contained in FILE (in
PEM or DER format) to validate the
identify of the server. The connection must
be secured with SSL/TLS (e.g. the service
URL must start 'amqps://')
use the certificate contained in FILE (in PEM format) to
validate the identity of the server. The connection must
be secured with SSL/TLS (e.g. the service URL must start
with 'amqps://')
-t TOPICPATTERN, --topic-pattern=TOPICPATTERN

@@ -551,7 +581,6 @@ subscribe to receive messages matching TOPICPATTERN

-c FILE, --trust-certificate=FILE
use the certificate contained in FILE (in
PEM or DER format) to validate the
identify of the server. The connection must
be secured with SSL/TLS (e.g. the service
URL must start 'amqps://')
use the certificate contained in FILE (in PEM format) to
validate the identity of the server. The connection must
be secured with SSL/TLS (e.g. the service URL must start
with 'amqps://')
-t TOPIC, --topic=TOPIC

@@ -575,4 +604,3 @@ send messages to topic TOPIC

You can help shape the product we release by trying out the beta code and
leaving your
[feedback](https://developer.ibm.com/community/groups/service/html/communityview?communityUuid=00a6a6d0-9601-44cb-a2a2-b0b26811790a).
leaving your [feedback](https://ibm.biz/mqlight-forum).

@@ -582,3 +610,3 @@ ### Reporting bugs

If you think you've found a bug, please leave us
[feedback](https://developer.ibm.com/community/groups/service/html/communityview?communityUuid=00a6a6d0-9601-44cb-a2a2-b0b26811790a).
[feedback](https://ibm.biz/mqlight-forum).
To help us fix the bug a log might be helpful. You can get a log by setting the

@@ -590,5 +618,6 @@ environment variable `MQLIGHT_NODE_LOG` to `debug` and by collecting the output

### 1.0.2014111002
### 1.0.2015021700-beta
* Minor fix to mqlight-log.js
* Dependency on OpenSSL libraries removed.
* ...

@@ -595,0 +624,0 @@

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/samples/recv.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/samples/recv.js
*/
/*

@@ -65,7 +68,9 @@ * <copyright

puts(' -c FILE, --trust-certificate=FILE\n' +
' use the certificate contained in FILE (in\n' +
' PEM or DER format) to validate the\n' +
' identify of the server. The connection must\n' +
' be secured with SSL/TLS (e.g. the service\n' +
" URL must start 'amqps://')");
' use the certificate contained in FILE (in PEM' +
' format) to\n' +
' validate the identity of the server. The' +
' connection must\n' +
' be secured with SSL/TLS (e.g. the service URL' +
' must start\n' +
" with 'amqps://')");
puts(' -t TOPICPATTERN, --topic-pattern=TOPICPATTERN\n' +

@@ -128,3 +133,3 @@ ' subscribe to receive messages matching' +

console.error('*** error ***');
console.error("The service URL must start 'amqps://' when using a " +
console.error("The service URL must start with 'amqps://' when using a " +
'trust certificate.');

@@ -131,0 +136,0 @@ console.error('Exiting.');

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/samples/send.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/samples/send.js
*/
/*

@@ -64,7 +67,9 @@ * <copyright

puts(' -c FILE, --trust-certificate=FILE\n' +
' use the certificate contained in FILE (in\n' +
' PEM or DER format) to validate the\n' +
' identify of the server. The connection must\n' +
' be secured with SSL/TLS (e.g. the service\n' +
" URL must start 'amqps://')");
' use the certificate contained in FILE (in PEM' +
' format) to\n' +
' validate the identity of the server. The' +
' connection must\n' +
' be secured with SSL/TLS (e.g. the service URL' +
' must start\n' +
" with 'amqps://')");
puts(' -t TOPIC, --topic=TOPIC');

@@ -116,3 +121,3 @@ puts(' send messages to topic TOPIC\n' +

console.error('*** error ***');
console.error("The service URL must start 'amqps://' when using a " +
console.error("The service URL must start with 'amqps://' when using a " +
'trust certificate.');

@@ -119,0 +124,0 @@ console.error('Exiting.');

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/samples/uiworkout.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/samples/uiworkout.js
*/
/*

@@ -85,7 +88,9 @@ * <copyright

puts(' -c FILE, --trust-certificate=FILE\n' +
' use the certificate contained in FILE (in\n' +
' PEM or DER format) to validate the\n' +
' identify of the server. The connection must\n' +
' be secured with SSL/TLS (e.g. the service\n' +
" URL must start 'amqps://')");
' use the certificate contained in FILE (in PEM' +
' format) to\n' +
' validate the identity of the server. The' +
' connection must\n' +
' be secured with SSL/TLS (e.g. the service URL' +
' must start\n' +
" with 'amqps://')");
puts('');

@@ -219,3 +224,3 @@ };

if (err) {
console.err('Problem with send request: ' + err.message);
console.error('Problem with send request: ' + err.message);
process.exit(0);

@@ -222,0 +227,0 @@ } else {

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/stubs/stubproton.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/stubs/stubproton.js
*/
/*

@@ -23,4 +26,8 @@ * <copyright

var DEBUG = false;
var util = require('util');
var Duplex = require('stream').Duplex;
var DEBUG = process.env.MQLIGHT_NODE_STUB_DEBUG || false;
var log = process.env.MQLIGHT_NODE_STUB_LOG_ERROR ? console.error : console.log;
var connectStatus = 0;

@@ -35,3 +42,3 @@

exports.setConnectStatus = function(status) {
if (DEBUG) console.log('setting connect status to: ' + status);
if (DEBUG) log('setting connect status to: ' + status);
connectStatus = status;

@@ -48,3 +55,3 @@ };

exports.blockSendCompletion = function() {
if (DEBUG) console.log('blocking send completion');
if (DEBUG) log('blocking send completion');
sendStatus = 1; // PN_STATUS_PENDING = 1

@@ -58,3 +65,3 @@ };

exports.unblockSendCompletion = function() {
if (DEBUG) console.log('unblocking send completion');
if (DEBUG) log('unblocking send completion');
sendStatus = 7;

@@ -76,3 +83,3 @@ };

exports.setRemoteIdleTimeout = function(interval, callback) {
if (DEBUG) console.log('setRemoteIdleTimeout to ' + interval);
if (DEBUG) log('setRemoteIdleTimeout to ' + interval);
remoteIdleTimeout = interval;

@@ -93,3 +100,3 @@ workCallback = callback;

send: function() {
if (DEBUG) console.log('stub send function called');
if (DEBUG) log('stub send function called');
},

@@ -101,19 +108,32 @@ status: function(msg) {

}
if (DEBUG) console.log('stub status function called, returning: ',
result);
if (DEBUG) log('stub status function called, returning: ', result);
return result;
},
statusError: function() {
if (DEBUG) console.log('stub statusError function called');
if (DEBUG) log('stub statusError function called');
return '';
},
accept: function() {
if (DEBUG) console.log('stub accept function called');
if (DEBUG) log('stub accept function called');
},
settle: function() {
if (DEBUG) console.log('stub settle function called');
if (DEBUG) log('stub settle function called');
},
connect: function(service, sslTrustCertificate, sslVerifyName) {
if (DEBUG) console.log('stub connect function called for service: ' +
service, sslTrustCertificate, sslVerifyName);
settledCount: 0,
settled: function() {
if (DEBUG) log('stub settled function called');
if (connectStatus !== 0) {
var err = new Error('error on settle: ' + connectStatus);
err.name = 'NetworkError';
throw err;
} else {
if (++this.settledCount >= 2) {
return true;
} else {
return false;
}
}
},
connect: function(service) {
if (DEBUG) log('stub connect function called for service: ' + service);
if (!this.stopped) throw new Error('already connected');

@@ -124,8 +144,2 @@ var href = service.href;

err = new TypeError('bad service ' + href);
} else if (sslTrustCertificate === 'BadCertificate') {
err = new Error('Bad Certificate');
err.name = 'SecurityError';
} else if (sslTrustCertificate === 'BadVerify' && sslVerifyName) {
err = new Error('Bad verify name');
err.name = 'SecurityError';
} else {

@@ -138,3 +152,3 @@ if (connectStatus !== 0) {

this.stopped = false;
if (DEBUG) console.log('successfully connected');
if (DEBUG) log('successfully connected');
}

@@ -146,3 +160,3 @@ }

// Commented - as generates a lot of output...
// if (DEBUG) console.log('stub receive function called');
// if (DEBUG) log('stub receive function called');
return [];

@@ -152,3 +166,3 @@ },

stop: function() {
if (DEBUG) console.log('stub stop function called');
if (DEBUG) log('stub stop function called');
if (!this.stopped) {

@@ -161,39 +175,94 @@ this.stopCount--;

}
if (DEBUG) console.log('stub stop function returning: '+this.stopped);
if (DEBUG) log('stub stop function returning: '+this.stopped);
return this.stopped;
},
put: function(msg, qos) {
if (DEBUG) console.log('stub put function called');
if (DEBUG) log('stub put function called');
msg.unitTestQos = qos;
},
hasSent: function() {
if (DEBUG) console.log('stub hasSent function called');
if (DEBUG) log('stub hasSent function called');
return true;
},
started: function() {
return true;
},
stopped: true,
subscribe: function() {
if (DEBUG) console.log('stub subscribe function called');
if (DEBUG) log('stub subscribe function called');
},
subscribedCount: 0,
subscribed: function(address) {
if (DEBUG) log('stub subscribed function called with address ' +
address);
if (connectStatus !== 0) {
var err = new Error('error on subscribe: ' + connectStatus);
err.name = 'NetworkError';
throw err;
} else {
if (++this.subscribedCount >= 2) {
this.subscribedCount = 0;
return true;
} else {
return false;
}
}
},
unsubscribe: function() {
if (DEBUG) console.log('stub unsubscribe function called');
if (DEBUG) log('stub unsubscribe function called');
},
unsubscribedCount: 0,
unsubscribed: function(address) {
if (DEBUG) log('stub unsubscribed function called with ' +
'address ' + address);
if (connectStatus !== 0) {
var err = new Error('error on unsubscribe: ' + connectStatus);
err.name = 'NetworkError';
throw err;
} else {
if (++this.unsubscribedCount >= 2) {
this.unsubscribedCount = 0;
return true;
} else {
return false;
}
}
},
getRemoteIdleTimeout: function(address) {
if (DEBUG) console.log('stub getRemoteIdleTimeout function called, ' +
'returning: ' + remoteIdleTimeout);
if (DEBUG) log('stub getRemoteIdleTimeout function called, ' +
'returning: ' + remoteIdleTimeout);
return remoteIdleTimeout;
},
work: function(timeout) {
if (DEBUG) console.log('stub work function called with timeout: ' +
timeout);
if (workCallback) workCallback.apply();
return 0;
},
flow: function(linkAddress, credit) {
if (DEBUG) console.log('stub flow function called with link address: ' +
linkAddress + ' and credit: ' + credit);
if (DEBUG) log('stub flow function called with link address: ' +
linkAddress + ' and credit: ' + credit);
},
pendingOutbound: function(address) {
if (DEBUG) console.log('pendingOutbound function called with address ' +
address);
if (DEBUG) log('pendingOutbound function called with address ' +
address);
return false;
},
pushCount: 0,
push: function(length, chunk) {
var result = length;
if (++this.pushCount === 5) {
result--;
} else if (this.pushCount === 6) {
this.pushCount = 0;
result = 0;
}
if (DEBUG) log('stub push function called, returning:', result);
return result;
},
pop: function(stream, force) {
if (DEBUG) log('stub pop function called with force: ' + force);
return 0;
},
closed: function() {
if (DEBUG) log('stub closed function called');
return 0;
},
heartbeat: function() {
if (DEBUG) log('stub heartbeat function called');
if (workCallback) workCallback.apply();
}

@@ -203,3 +272,3 @@ },

createMessenger: function() {
if (DEBUG) console.log('stub createMessenger function called');
if (DEBUG) log('stub createMessenger function called');
connectStatus = 0;

@@ -211,10 +280,98 @@ this.messenger.stopped = true;

createMessage: function() {
if (DEBUG) console.log('stub createMessage function called');
if (DEBUG) log('stub createMessage function called');
return {
destroy: function() {
if (DEBUG) console.log('stub destroy function called');
if (DEBUG) log('stub destroy function called');
}
};
},
connect: function(options, callback) {
if (DEBUG) log('stub proton connect function called with options ' +
options);
return new StubStream(options, callback);
}
};
};
/**
* A stub connection to the Server implemented as a Duplex
* Stream.
*
* @constructor
* @param {object} options stream options.
* @param {Function} callback connect callback.
* @return {object} a stub connection.
*/
var StubStream = function(options, callback) {
if (DEBUG) log('StubStream constructor called');
var stream = this;
if (!(stream instanceof StubStream))
return new StubStream(options);
Duplex.call(stream, options);
stream.ended = false;
stream.connError = false;
stream.authorized = true;
stream.authorizationError = null;
var err = null;
if (options.host.indexOf('bad') != -1) {
err = new TypeError('ECONNREFUSED bad service ' + options.host);
} else if (options.sslTrustCertificate === 'BadCertificate') {
stream.authorized = false,
stream.authorizationError = new Error('Bad Certificate');
} else if (options.sslTrustCertificate === 'BadVerify' &&
options.sslVerifyName) {
stream.authorized = false,
stream.authorizationError = new Error('Bad verify name');
} else if (connectStatus !== 0) {
err = new Error('connect error: ' + connectStatus);
err.name = 'NetworkError';
}
if (err) {
stream.connError = true;
if (DEBUG) log('emitting error event');
process.nextTick(function() {
stream.emit('error', err);
});
} else {
if (DEBUG) log('connection made');
process.nextTick(function() {
callback.apply(stream, []);
});
}
stream._read = function(size) {
if (DEBUG) log('stream _read function called for size:', size);
};
stream._write = function(chunk, encoding, callback) {
if (DEBUG) log('stream _write function called for chunk size:',
chunk.length);
};
stream.end = function() {
if (DEBUG) log('stream end function called');
stream.ended = true;
stream.push(null);
};
var pushData = function(stream) {
if (!stream.ended) {
stream.push('chunk');
setImmediate(function() {
pushData(stream);
});
}
};
setImmediate(function(stream) {
pushData(stream)
}, stream);
};
util.inherits(StubStream, Duplex);

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/testcreateclient.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/testcreateclient.js
*/
/*

@@ -73,3 +76,3 @@ * <copyright

test.throws(function() {
mqlight.createClient({service: 123});
mqlight.createClient({service: 123, id: 'test_service_not_a_string'});
}, function(err) {

@@ -120,3 +123,5 @@ if ((err instanceof TypeError) &&

test.throws(function() {
mqlight.createClient({}, 1);
mqlight.createClient({
id: 'test_createClient_callback_must_be_function'
}, 1);
}, function(err) {

@@ -158,2 +163,3 @@ if ((err instanceof TypeError) &&

oddOpts.service = 'amqp://localhost';
oddOpts.id = 'test_createClient_ignores_unknown_properties';
oddOpts.fruit = 'avocado';

@@ -182,3 +188,3 @@ oddOpts.size = 3;

{data: new Array(50).join('x'), valid: false},
{data: '%._', valid: true}];
{data: 'abcDEF._/%', valid: true}];

@@ -246,2 +252,3 @@ var runTest = function(i) {

service: 'amqp://localhost:5672',
id: 'test_user_password_types_values'+i,
user: testData[i].user,

@@ -283,2 +290,3 @@ password: testData[i].password

service: 'amqp://localhost:5672',
id: 'test_password_hidden',
user: 'bob',

@@ -290,2 +298,3 @@ password: 's3cret'

test.ok(!/s3cret/.test(inspectedClient), inspectedClient);
client.stop();
test.done();

@@ -312,3 +321,3 @@ };

service: invalidUris[i],
id: 'test_invalid_URIs'
id: 'test_invalid_URIs'+i
};

@@ -344,3 +353,6 @@ mqlight.createClient(opts);

var clientTest = function(uri, expected) {
var client = mqlight.createClient({service: uri});
var client = mqlight.createClient({
service: uri,
id: 'test_valid_URIs'+count
});
client.start(function(err) {

@@ -369,3 +381,8 @@ test.ok(!err);

module.exports.test_createClient_too_many_arguments = function(test) {
mqlight.createClient({service: 'amqp://host'}, function() {}, 'wallflower');
mqlight.createClient({
service: 'amqp://host',
id: 'test_createClient_too_many_arguments'
}, function(err) {
test.ok(!err);
}, 'wallflower').stop();
test.done();

@@ -480,3 +497,4 @@ };

var count = 0;
var validSSLTest = function(sslTrustCertificate, sslVerifyName) {
var invalidSSLTest = function(sslTrustCertificate, sslVerifyName) {
var firstError = true;
var opts = {

@@ -486,3 +504,3 @@ service: 'amqp://host',

sslVerifyName: testData[count].sslVerifyName,
id: 'test_invalid_ssl_options'
id: 'test_invalid_ssl_options'+count
};

@@ -492,11 +510,16 @@ var client = mqlight.createClient(opts);

test.ok(err);
client.stop();
++count;
if (count == testData.length) {
test.done();
fs.close(badCertificateFd); fs.unlinkSync('BadCertificate');
fs.close(badVerifyFd); fs.unlinkSync('BadVerify');
} else {
validSSLTest(testData[count].sslTrustCertificate,
testData[count].sslVerifyName);
test.equal('SecurityError', err.name, 'Expected a SecurityError');
if(firstError) {
firstError = false;
client.stop(function () {
++count;
if (count == testData.length) {
test.done();
fs.close(badCertificateFd); fs.unlinkSync('BadCertificate');
fs.close(badVerifyFd); fs.unlinkSync('BadVerify');
} else {
invalidSSLTest(testData[count].sslTrustCertificate,
testData[count].sslVerifyName);
}
});
}

@@ -514,3 +537,3 @@ });

validSSLTest(testData[count].sslTrustCertificate,
invalidSSLTest(testData[count].sslTrustCertificate,
testData[count].sslVerifyName);

@@ -526,2 +549,3 @@ };

module.exports.test_createClient_multiple_with_same_id = function(test) {
test.expect(14);
var optsA = { service: 'amqp://localhost', id: 'Aname' };

@@ -573,1 +597,42 @@ var optsB = { service: 'amqp://localhost', id: 'Bname' };

};
/**
* Test that, calling createClient a second time with the same id is
* successful, replacing (invalidating) the previous instance,
* even when it's in retrying state.
* @param {object} test - test case.
*/
module.exports.test_createClient_multiple_with_same_id_retry = function(test) {
var optsA = { service: 'amqp://localhost', id: 'Aname2' };
var optsB1 = { service: 'amqp://bad', id: 'Bname2' };
var optsB2 = { service: 'amqp://localhost', id: 'Bname2' };
var clientA = mqlight.createClient(optsA, function(err) {
var firstTime = true;
var clientB1 = mqlight.createClient(optsB1, function(err) {
test.ok(err);
}).on('error', function(err) {
if (firstTime) {
firstTime = false;
test.equal('NetworkError', err.name, 'expected a NetworkError');
var clientB2 = mqlight.createClient(optsB2, function(err) {
test.deepEqual(null, err);
test.equal('started', clientA.state);
test.equal('stopped', clientB1.state);
test.equal('started', clientB2.state);
clientA.stop(function() {
clientB2.stop(function() {
test.done();
});
});
}).on('error', function(err) {
test.equal('ReplacedError', err.name, 'expected a ReplacedError');
});
} else {
test.equal('ReplacedError', err.name, 'expected a ReplacedError');
}
});
});
};

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/testexample.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/testexample.js
*/
/*

@@ -3,0 +6,0 @@ * <copyright

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/testgjslint.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/testgjslint.js
*/
/*

@@ -3,0 +6,0 @@ * <copyright

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/testreceivemessage.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/testreceivemessage.js
*/
/*

@@ -61,4 +64,11 @@ * <copyright

mqlight.proton.messenger.receive = function() {};
var subscriptions = 0;
var cb = function() {
subscriptions++;
};
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_receive_message'}
);

@@ -74,9 +84,10 @@ var first = true;

test.deepEqual(delivery.destination.topicPattern, '/kittens/+/boots');
test.done();
client.stop();
mqlight.proton.messenger.receive = originalReceiveMethod;
client.stop(function() {
test.done();
});
}
});
client.subscribe('/kittens/#');
client.subscribe('/kittens/+/boots');
client.subscribe('/kittens/#', cb);
client.subscribe('/kittens/+/boots', cb);
});

@@ -96,5 +107,9 @@

mqlight.proton.messenger.receive = function() {
var result = messages;
messages = [];
return result;
if (subscriptions == 2) {
var result = messages;
messages = [];
return result;
} else {
return [];
}
};

@@ -118,3 +133,7 @@ };

var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_receive_topic_pattern'}
);
client.start(function() {

@@ -140,5 +159,6 @@ client.subscribe('/kittens/#');

test.done();
client.stop();
mqlight.proton.messenger.receive = originalReceiveMethod;
client.stop(function() {
test.done();
});
});

@@ -196,5 +216,6 @@

process.removeListener('uncaughtException', handler);
test.done();
client.stop();
mqlight.proton.messenger.receive = originalReceiveMethod;
client.stop(function() {
test.done();
});
});

@@ -243,3 +264,7 @@ client.subscribe('/public');

var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_malformed_message'}
);
client.start(function() {

@@ -268,5 +293,6 @@ client.subscribe('/kittens/#');

test.deepEqual(delivery.malformed.MQMD.Format, 'MQAMQP');
test.done();
client.stop();
mqlight.proton.messenger.receive = originalReceiveMethod;
client.stop(function() {
test.done();
});
});

@@ -306,3 +332,7 @@

var count = 0;
var client = mqlight.createClient({service: 'amqp://localhost'});
var client = mqlight.createClient({
service: 'amqp://localhost',
id: 'test_receive_ttl'}
);
client.start(function() {

@@ -322,4 +352,5 @@ client.subscribe('/public');

if (++count === messages.length) {
client.stop();
test.done();
client.stop(function() {
test.done();
});
}

@@ -336,2 +367,3 @@ });

* @param {object} test - the unittest interface
* @param {String} name - the test name
* @param {Number} credit - the credit value to supply to client.subscribe(...)

@@ -341,3 +373,3 @@ * @param {Number} qos - the qos level to use for the test

*/
function run_receiver_credit_testcase(test, credit, qos, numMessages) {
function run_receiver_credit_testcase(test, name, credit, qos, numMessages) {

@@ -349,18 +381,4 @@ var savedReceiveMethod = mqlight.proton.messenger.receive;

var currentCredit = maxCredit;
mqlight.proton.messenger.receive = function() {
test.ok(currentCredit >= 0, 'credit should never be negative');
if (currentCredit > 0) {
--currentCredit;
return [testMessage('/kittens/wearing/boots', '/kittens/#')];
} else {
return [];
}
};
mqlight.proton.messenger.flow = function(linkAddress, credit) {
currentCredit += credit;
test.ok(currentCredit <= maxCredit,
'maximum credit for link should never be exceeded');
};
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({service: 'amqp://host', id: name});

@@ -373,10 +391,28 @@ client.start(function(err) {

if (++receiveCount >= numMessages) {
client.stop();
mqlight.proton.messenger.receive = savedReceiveMethod;
mqlight.proton.messenger.flow = savedFlowMethod;
test.done();
client.stop(function() {
test.done();
});
}
});
client.subscribe('/kittens/#', {qos: qos, credit: maxCredit});
client.subscribe('/kittens/#', {qos: qos, credit: maxCredit},
function (err, topicPattern, share) {
mqlight.proton.messenger.receive = function() {
test.ok(currentCredit >= 0, 'credit should never be negative');
if (currentCredit > 0) {
--currentCredit;
return [testMessage('/kittens/wearing/boots', '/kittens/#')];
} else {
return [];
}
};
mqlight.proton.messenger.flow = function(linkAddress, credit) {
currentCredit += credit;
test.ok(currentCredit <= maxCredit,
'maximum credit for link should never be exceeded');
};
}
);
});

@@ -401,3 +437,4 @@

module.exports.test_subscribe_credit10_qos0 = function(test) {
run_receiver_credit_testcase(test, 10, 0, 250);
run_receiver_credit_testcase(test, 'test_subscribe_credit10_qos0',
10, 0, 250);
};

@@ -413,3 +450,4 @@

module.exports.test_subscribe_credit5000_qos0 = function(test) {
run_receiver_credit_testcase(test, 5000, 0, 20000);
run_receiver_credit_testcase(test, 'test_subscribe_credit5000_qos0',
5000, 0, 20000);
};

@@ -425,3 +463,4 @@

module.exports.test_subscribe_credit1_qos0 = function(test) {
run_receiver_credit_testcase(test, 1, 0, 50);
run_receiver_credit_testcase(test, 'test_subscribe_credit1_qos0',
1, 0, 50);
};

@@ -437,3 +476,4 @@

module.exports.test_subscribe_credit10_qos1 = function(test) {
run_receiver_credit_testcase(test, 10, 0, 250);
run_receiver_credit_testcase(test, 'test_subscribe_credit10_qos1',
10, 0, 250);
};

@@ -449,3 +489,4 @@

module.exports.test_subscribe_credit5000_qos1 = function(test) {
run_receiver_credit_testcase(test, 5000, 0, 20000);
run_receiver_credit_testcase(test, 'test_subscribe_credit5000_qos1',
5000, 0, 20000);
};

@@ -461,3 +502,4 @@

module.exports.test_subscribe_credit1_qos1 = function(test) {
run_receiver_credit_testcase(test, 1, 0, 50);
run_receiver_credit_testcase(test, 'test_subscribe_credit1_qos1',
1, 0, 50);
};

@@ -479,20 +521,7 @@

var currentCredit = maxCredit;
mqlight.proton.messenger.receive = function() {
test.ok(currentCredit >= 0, 'credit should never be negative');
if (currentCredit > 0) {
--currentCredit;
return [testMessage('/kittens/wearing/boots', '/kittens/#')];
} else {
return [];
}
};
mqlight.proton.messenger.flow = function(linkAddress, credit) {
test.ok((currentCredit + credit) <= maxCredit,
'maximum credit for link should never be exceeded,'+
' current: ' + currentCredit + ' flowed: ' + credit +
' max: ' + maxCredit);
currentCredit += credit;
};
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_subscribe_credit_confirm'
});
var deliveryArray = [];

@@ -511,6 +540,7 @@ var interval = null;

test.ok(confirmBatch === 4);
client.stop();
mqlight.proton.messenger.receive = savedReceiveMethod;
mqlight.proton.messenger.flow = savedFlowMethod;
test.done();
client.stop(function() {
test.done();
});
}

@@ -520,5 +550,23 @@ });

client.subscribe('/kittens/#',
{qos: 1, credit: maxCredit, autoConfirm: false});
{qos: 1, credit: maxCredit, autoConfirm: false},
function (err, topicPattern, share) {
mqlight.proton.messenger.receive = function() {
test.ok(currentCredit >= 0, 'credit should never be negative');
if (currentCredit > 0) {
--currentCredit;
return [testMessage('/kittens/wearing/boots', '/kittens/#')];
} else {
return [];
}
};
mqlight.proton.messenger.flow = function(linkAddress, credit) {
test.ok((currentCredit + credit) <= maxCredit,
'maximum credit for link should never be exceeded,'+
' current: ' + currentCredit + ' flowed: ' + credit +
' max: ' + maxCredit);
currentCredit += credit;
};
}
);
interval = setInterval(function() {

@@ -554,6 +602,6 @@ ++confirmBatch;

*/
module.exports.test_client_replaced = function(test) {
module.exports.test_receive_client_replaced = function(test) {
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_client_replaced'
id: 'test_subscribe_client_replaced'
});

@@ -573,4 +621,5 @@

mqlight.proton.messenger.receive = savedReceiveMethod;
client.stop();
test.done();
client.stop(function() {
test.done();
});
});

@@ -592,7 +641,7 @@

* Tests that the confirmDelivery() method is passed to the 'message' event when
* a message is received as a result of subscribing using
* a message is received as a result of subscribing using
* {qos: 1, autoConfirm: false} options on the client.subscribe() method
* <p>
* Also check that the confirmDelivery() method is not passed to the 'message'
* event when the delivery cannot be confirmed (e.g. qos: 0 OR
* event when the delivery cannot be confirmed (e.g. qos: 0 OR
* autoConfirm: true).

@@ -624,3 +673,6 @@ *

var client = mqlight.createClient({service: 'amqp://host'}, function() {
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_presence_of_confirmDelivery_method'
}, function() {
client.subscribe('/kittens/#', testData[testCase].options);

@@ -639,57 +691,14 @@ messages.push(testMessage('/kittens/blacktail', '/kittens/#'));

}
client.unsubscribe('/kittens/#');
++testCase;
if (testCase < testData.length) {
client.subscribe('/kittens/#', testData[testCase].options);
messages.push(testMessage('/kittens/blacktail', '/kittens/#'));
} else {
test.done();
client.stop();
mqlight.proton.messenger.receive = originalReceiveMethod;
}
});
client.on('malformed', function() {
test.ok(false, 'malformed event should not be emitted');
});
client.on('error', function(err) {
console.log(err, 'error event should not be emitted');
test.ok(false);
});
};
/**
* Tests that the pn_messenger_work function is invoked each time a
* message is delivered. This is required to avoid a situation where the loop
* that is responsible for delivering messages is so busy - heart beats are
* never responded to and the server disconnects the client believing that it
* has ended.
* @param {object} test the unittest interface
*/
module.exports.test_work_between_messages = function(test) {
var originalReceiveMethod = mqlight.proton.messenger.receive;
var originalWorkMethod = mqlight.proton.messenger.work;
mqlight.proton.messenger.receive = function() {};
var client = mqlight.createClient({service: 'amqp://host'});
var messageEvents = 0;
var workCalls = 0;
client.start(function(err) {
test.ifError(err);
client.on('message', function(data, delivery) {
++messageEvents;
if (messageEvents === 2) {
client.stop();
client.unsubscribe('/kittens/#', function(err, topicPattern, share) {
++testCase;
if (testCase < testData.length) {
client.subscribe('/kittens/#', testData[testCase].options);
messages.push(testMessage('/kittens/blacktail', '/kittens/#'));
} else {
mqlight.proton.messenger.receive = originalReceiveMethod;
mqlight.proton.messenger.work = originalWorkMethod;
test.ok(workCalls > 0, 'expected work to be invoked!');
test.done();
client.stop(function() {
test.done();
});
}
});
client.subscribe('/#');
});

@@ -705,15 +714,2 @@

});
var messages = [testMessage('/test_work_between_messages', '/#'),
testMessage('/test_work_between_messages', '/#')];
mqlight.proton.messenger.receive = function() {
var result = messages;
messages = [];
return result;
};
mqlight.proton.messenger.work = function() {
++workCalls;
return 0;
};
};

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/testrestart.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/testrestart.js
*/
/*

@@ -45,4 +48,4 @@ * <copyright

test.ok(false, 'Test timed out waiting for events to be emitted');
if (client) client.stop();
test.done();
if (client) client.stop();
}, 5000);

@@ -65,5 +68,6 @@

test.deepEqual(client.state, 'started', 'client has restarted');
client.stop();
test.done();
clearTimeout(timeout);
client.stop(function() {
test.done();
});
});

@@ -112,4 +116,4 @@ };

test.ok(false, 'Test timed out waiting for events to be emitted');
if (client) client.stop();
test.done();
if (client) client.stop();
}, 5000);

@@ -134,5 +138,6 @@ client.on('started', function(x, y) {

test.equals(reconnectedEvents, 1, 'reconnected event happened once');
client.stop();
test.done();
clearTimeout(timeout);
client.stop(function() {
test.done();
});
},1000);

@@ -151,3 +156,3 @@ });

module.exports.test_resubscribe_on_restart = function(test) {
test.expect(7);
test.expect(13);
var client = mqlight.createClient({id: 'test_resubscribe_on_restart',

@@ -158,4 +163,5 @@ service: 'amqp://host'});

test.ok(false, 'Test timed out waiting for events to be emitted');
test.done();
if (client) client.stop();
if (client) client.stop(function() {
test.done();
});
}, 5000);

@@ -178,7 +184,25 @@

client.subscribe('/topic', 'myshare', function(err) {
test.ok(!err);
if (connectErrors > 0) return;
client.subscribe('/another/topic', function(err) {
test.ok(!err);
if (connectErrors > 0) return;
client.subscribe('/final/topic/', 'diffshare', function(err) {
if (connectErrors > 0) return;
test.ok(!err);
if (connectErrors > 0) {
if (err) return;
test.equal(client._subscriptions.length, origSubsList.length,
'after reconnect subs lists does not match original');
while (client._subscriptions.length > 0) {
var expected = origSubsList.pop();
expected.callback = undefined;
var actual = client._subscriptions.pop();
actual.callback = undefined;
test.deepEqual(actual, expected, 'sub list objects do not match');
}
clearTimeout(timeout);
client.stop(function() {
test.done();
});
}
if (connectErrors === 0) {

@@ -200,13 +224,2 @@ setImmediate(function() {

test.equal(3, origSubsList.length, 'origSubsList length is wrong');
test.equal(client._subscriptions.length, origSubsList.length,
'after reconect subs lists does not match original');
while (client._subscriptions.length > 0) {
var expected = origSubsList.pop();
expected.callback = undefined;
var actual = client._subscriptions.pop();
actual.callback = undefined;
test.deepEqual(actual, expected, 'sub list objects do not match');
}
test.done();
clearTimeout(timeout);
});

@@ -229,4 +242,4 @@ });

test.ok(false, 'Test timed out waiting for events to be emitted');
if (client) client.stop();
test.done();
if (client) client.stop();
}, 5000);

@@ -252,6 +265,7 @@

setTimeout(function() {
client.stop();
clearTimeout(timeout);
client.removeAllListeners();
test.done();
clearTimeout(timeout);
client.stop(function() {
test.done();
});
},1000);

@@ -281,4 +295,4 @@ });

mqlight.proton.messenger.send = savedSendFunction;
if (client) client.stop();
test.done();
if (client) client.stop();
}, 5000);

@@ -294,5 +308,6 @@

test.equals(client._queuedSends.length, 0, 'queued sends now 0');
client.stop();
clearTimeout(timeout);
test.done();
client.stop(function() {
test.done();
});
});

@@ -320,3 +335,3 @@ });

*/
module.exports.test_queue_sends_retrying = function(test) {
module.exports.test_queued_sends_retrying = function(test) {
test.expect();

@@ -340,2 +355,7 @@ var client = mqlight.createClient({id: 'test_queued_sends_retrying', service:

client.on('error', function(err) {
test.deepEqual(client.state, 'retrying',
'client in retrying state after error');
});
client.start(function(err) {

@@ -381,7 +401,2 @@ stubproton.setConnectStatus(1);

var savedSubFunction = mqlight.proton.messenger.subscribe;
mqlight.proton.messenger.subscribe = function() {
throw new Error('error on subscribe');
};
var subscribeErrors = 0;

@@ -398,3 +413,2 @@ client.on('error', function(err) {

client._queuedSubscriptions.length);
mqlight.proton.messenger.subscribe = savedSubFunction;
stubproton.setConnectStatus(0);

@@ -476,5 +490,5 @@ setTimeout(function(){client.stop();},500);

var savedUnsubscribeFn = mqlight.proton.messenger.unsubscribe;
mqlight.proton.messenger.unsubscribe = function() {
throw new Error('error on unsubscribe');
var savedSubscribedFn = mqlight.proton.messenger.subscribed;
mqlight.proton.messenger.subscribed = function() {
return true;
};

@@ -493,5 +507,5 @@

client._queuedUnsubscribes.length);
mqlight.proton.messenger.unsubscribe = savedUnsubscribeFn;
mqlight.proton.messenger.subscribed = savedSubscribedFn;
stubproton.setConnectStatus(0);
setTimeout(function() {client.stop();},500);
setTimeout(function() {client.stop();},1500);
}

@@ -505,5 +519,9 @@ });

for (var i = 1; i < 5; i++) {
client.subscribe('queue' + i);
client.unsubscribe('queue' + i, function() {
successCallbacks++;
client.subscribe('queue' + i, function(err, topicPattern, share) {
if (unsubscribeErrors >= 4) return;
client.unsubscribe(topicPattern, function(err) {
if (!err) {
successCallbacks++;
}
});
});

@@ -658,4 +676,6 @@ }

for (var j = 2; j < 5; j += 2) {
client.unsubscribe('queue' + j, function() {
successCallbacks++;
client.unsubscribe('queue' + j, function(err) {
if (!err) {
successCallbacks++;
}
});

@@ -753,3 +773,3 @@ }

'should be no queued subs');
setTimeout(function() { client.stop() }, 10);
setTimeout(function() { client.stop() }, 20);
});

@@ -756,0 +776,0 @@

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/testsend.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/testsend.js
*/
/*

@@ -58,3 +61,3 @@ * <copyright

* Test that if too many arguments are supplied to client.send(...) then the
* additional arguments are ignore.
* additional arguments are ignored.
* @param {object} test the unittest interface

@@ -79,2 +82,25 @@ */

/**
* Test that if a bad callback is specified then an exception is
* thrown.
*
* @param {object} test the unittest interface
*/
module.exports.test_send_callback_must_be_a_function = function(test) {
var client = mqlight.createClient({
id: 'test_send_callback_must_be_a_function',
service: 'amqp://host'});
client.on('started', function() {
test.throws(
function() {
client.send('topic', 'message', {}, 123);
}
);
client.stop(function() {
test.done();
});
});
};
/**
* Test a variety of valid and invalid topic names. Invalid topic names

@@ -408,3 +434,3 @@ * should result in the client.send(...) method throwing a TypeError.

module.exports.test_clear_queuedsends_disconnect = function(test) {
//test.expect(3);
test.expect(3);
var client = mqlight.createClient({id: 'test_clear_queuedsends_disconnect',

@@ -565,3 +591,3 @@ service: 'amqp://host'});

client.on('started', function() {
test.doesNotThrow(function() {

@@ -579,3 +605,3 @@ // Test that a message being rejected result in the send(...) method's

test.done();
});

@@ -594,6 +620,6 @@ });

*/
module.exports.test_client_replaced = function(test) {
module.exports.test_send_client_replaced = function(test) {
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_client_replaced'
id: 'test_send_client_replaced'
});

@@ -620,2 +646,3 @@

mqlight.proton.messenger.send = savedSendFunction;
client.stop();
test.done();

@@ -626,1 +653,34 @@ });

/**
* Unit test for the fix to defect 74527. Calls send twice, each time
* specifying a different callback. The expected behaviour is that both send
* calls complete in order and invoke their respective callbacks.
*
* @param {object} test the unittest interface
*/
module.exports.test_sends_call_correct_callbacks = function(test) {
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_sends_call_correct_callbacks'
});
var firstCallbackRun = false;
var secondCallbackRun = false;
client.once('started', function() {
client.send('topic', 'data', function(err) {
test.ok(!firstCallbackRun, 'first callback run twice!');
test.ok(!secondCallbackRun, 'second callback called before first(1)!');
firstCallbackRun = true;
});
client.send('topic', 'data', function(err) {
test.ok(!secondCallbackRun, 'second callback called twice!');
test.ok(firstCallbackRun, 'second callback called before first(2)!');
secondCallbackRun = true;
client.stop();
test.done();
});
});
};

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/teststart.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/teststart.js
*/
/*

@@ -33,2 +36,3 @@ * <copyright

var http = require('http');
var https = require('https');
var EventEmitter = require('events').EventEmitter;

@@ -47,4 +51,6 @@ var testCase = require('nodeunit').testCase;

test.expect(9);
var client =
mqlight.createClient({service: 'amqp://host'}, function(err, c) {
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_successful_start_stop'
}, function(err, c) {
test.equals('started', client.state);

@@ -78,3 +84,6 @@ test.ok(this === client);

module.exports.test_listener_fired_on_subsequent_tick = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_listener_fired_on_subsequent_tick'
});
client.on('started', function() {

@@ -93,3 +102,6 @@ client.stop();

module.exports.test_start_argument_is_function = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_start_argument_is_function'
});
test.throws(

@@ -102,2 +114,3 @@ function() {

);
client.stop();
test.done();

@@ -113,3 +126,6 @@ };

module.exports.test_start_method_returns_client = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_start_method_returns_client'
});
var result = client.start(function() {client.stop();});

@@ -122,9 +138,12 @@ test.ok(result === client);

/**
* Tests that calling start on an already start client has no effect
* other than to callback any supplied callback function to indicate
* success.
* Tests that calling start on an already started client has no
* effect other than to callback any supplied callback function
* to indicate success.
* @param {object} test the unittest interface
*/
module.exports.test_start_when_already_started = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_start_when_already_started'
});
client.start(function(err) {

@@ -145,2 +164,47 @@ client.on('started', function(err) {

/**
* Tests that when calling start multiple times, all callbacks
* get invoked.
* @param {object} test the unittest interface
*/
module.exports.test_start_all_callbacks_called = function(test) {
var count = 0;
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_start_all_callbacks_called'
});
var started = function(err) {
test.ok(!err);
count++;
if (count == 3) {
client.stop();
test.done();
}
};
client.start(started);
client.start(started);
client.start(started);
};
/**
* Tests that when calling start, the callback gets invoked even
* if nested inside another callback.
* @param {object} test the unittest interface
*/
module.exports.test_start_nested_callback = function(test) {
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_start_nested_callback'
}, function(err) {
test.ok(!err);
client.start(function(err) {
test.ok(!err);
client.stop();
test.done();
});
});
};
/**
* Test that if too many arguments are supplied to start - then they are

@@ -151,3 +215,6 @@ * ignored.

module.exports.test_start_too_many_arguments = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_start_too_many_arguments'
});
client.start(function() {

@@ -166,3 +233,6 @@ client.stop();

module.exports.test_start_retry = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_start_retry'
});
var requiredConnectStatus = 2;

@@ -194,3 +264,4 @@

var client = mqlight.createClient({
service: services
service: services,
id: 'test_start_multiple_endpoints'
});

@@ -223,6 +294,7 @@ client.start(function() {

var client = mqlight.createClient({
service: serviceFunction
service: serviceFunction,
id: 'test_start_variable_endpoints'
});
client.on('error', function(err) {
test.ok(err.message.indexOf('amqp://bad') != -1);
test.ok(err.message.indexOf('bad') != -1);
});

@@ -238,2 +310,38 @@ client.start(function() {

/**
* Tests that when calling start with a function to specify the
* endpoints invalid services are detected.
*
* @param {object} test the unittest interface
*/
module.exports.test_start_bad_endpoints = function(test) {
var services = [
{service: 123, error: 'TypeError: service must be a string or array type'},
{service: [], error: 'TypeError: service array is empty'},
{service: function() {}, error: 'TypeError: service cannot be a function'}
];
var index = 0;
var serviceFunction = function(callback) {
test.ok(index < services.length);
var result = services[index];
callback(undefined, result.service);
};
var startCallback = function(err) {
test.ok(err instanceof TypeError);
test.equal(err, services[index++].error, 'Incorrect error message');
if(index === services.length) {
this.stop();
test.done();
} else {
test.equals('stopped', this.state);
this.start(startCallback);
}
};
mqlight.createClient({
service: serviceFunction,
id: 'test_start_bad_endpoints'
}, startCallback);
};
/**
* Tests that calling start whilst still stopping will be

@@ -245,3 +353,4 @@ * successful only when the stop completes

var client = mqlight.createClient({
service: 'amqp://host'
service: 'amqp://host',
id: 'test_start_stop_timing'
});

@@ -298,7 +407,8 @@ client.start(function() {

var client = mqlight.createClient({
service: 'http://127.0.0.1:9999'
service: 'http://127.0.0.1:9999',
id: 'test_start_http_changing_endpoint'
});
client.on('error', function(err) {
test.ok(err.message.indexOf('amqp://bad1') != -1 ||
err.message.indexOf('amqp://bad2') != -1);
test.ok(err.message.indexOf('bad1') != -1 ||
err.message.indexOf('bad2') != -1);
});

@@ -352,7 +462,8 @@ client.start(function(err) {

var client = mqlight.createClient({
service: 'http://127.0.0.1:9999'
service: 'http://127.0.0.1:9999',
id: 'test_start_http_multiple_endpoints'
});
// error will be emitted for the last service in the returned endpoint list
client.on('error', function(err) {
test.ok(err.message.indexOf('amqp://bad4') != -1);
test.ok(err.message.indexOf('bad4') != -1);
});

@@ -387,3 +498,4 @@ client.start(function(err) {

var client = mqlight.createClient({
service: 'http://127.0.0.1:9999'
service: 'http://127.0.0.1:9999',
id: 'test_start_http_connection_refused'
}, function(err) {

@@ -400,2 +512,31 @@ test.ok(err instanceof Error);

/**
* Tests that calling start with a bad HTTPS URI returns the
* underlying http error message to the start callback.
*
* @param {object} test the unittest interface
*/
module.exports.test_start_https_connection_refused = function(test) {
var originalHttpsRequestMethod = https.request;
https.request = function(url, callback) {
var req = new EventEmitter();
req.setTimeout = function() {};
req.end = function() {
req.emit('error', new Error('connect ECONNREFUSED'));
};
return req;
};
var client = mqlight.createClient({
service: 'https://127.0.0.1:9999',
id: 'test_start_https_connection_refused'
}, function(err) {
test.ok(err instanceof Error);
test.ok(/connect ECONNREFUSED/.test(err));
client.stop();
test.done();
https.request = originalHttpsRequestMethod;
});
};
/**
* Tests that the HTTP URI returning malformed JSON is coped with.

@@ -427,3 +568,4 @@ *

var client = mqlight.createClient({
service: 'http://127.0.0.1:9999'
service: 'http://127.0.0.1:9999',
id: 'test_start_http_bad_json'
}, function(err) {

@@ -468,3 +610,4 @@ test.ok(err instanceof Error);

var client = mqlight.createClient({
service: 'http://127.0.0.1:9999'
service: 'http://127.0.0.1:9999',
id: 'test_start_http_bad_amqp_service'
}, function(err) {

@@ -498,3 +641,4 @@ test.ok(err instanceof Error);

var client = mqlight.createClient({
service: 'http://127.0.0.1:9999'
service: 'http://127.0.0.1:9999',
id: 'test_start_http_timeout'
}, function(err) {

@@ -516,2 +660,3 @@ test.ok(err instanceof Error);

module.exports.test_start_http_bad_status = function(test) {
var firstTime = true;
var originalHttpRequestMethod = http.request;

@@ -527,2 +672,6 @@ http.request = function(url, callback) {

if (callback) callback(res);
if (firstTime) {
firstTime = false;
res.emit('data', 'STATUSDATA');
}
res.emit('end');

@@ -537,7 +686,16 @@ } catch (e) {

var client = mqlight.createClient({
service: 'http://127.0.0.1:9999'
service: 'http://127.0.0.1:9999',
id: 'test_start_http_bad_status1'
}, function(err) {
test.ok(err instanceof Error);
test.ok(/failed with a status code of 404/.test(err));
test.ok(/failed with a status code of 404: STATUSDATA$/.test(err));
client.stop();
});
var client2 = mqlight.createClient({
service: 'http://127.0.0.1:9999',
id: 'test_start_http_bad_status2'
}, function(err) {
test.ok(err instanceof Error);
test.ok(/failed with a status code of 404$/.test(err));
client2.stop();
test.done();

@@ -577,7 +735,8 @@ http.request = originalHttpRequestMethod;

var client = mqlight.createClient({
service: 'file:///tmp/filename.json'
service: 'file:///tmp/filename.json',
id: 'test_start_file_changing_endpoint'
});
client.on('error', function(err) {
test.ok(err.message.indexOf('amqp://bad1') != -1 ||
err.message.indexOf('amqp://bad2') != -1);
test.ok(err.message.indexOf('bad1') != -1 ||
err.message.indexOf('bad2') != -1);
});

@@ -624,7 +783,8 @@ client.start(function(err) {

var client = mqlight.createClient({
service: 'file:///tmp/filename.json'
service: 'file:///tmp/filename.json',
id: 'test_start_file_multiple_endpoints'
});
// error will be emitted for the last service in the returned endpoint list
client.on('error', function(err) {
test.ok(err.message.indexOf('amqp://bad4') != -1);
test.ok(err.message.indexOf('bad4') != -1);
});

@@ -650,3 +810,4 @@ client.start(function(err) {

var client = mqlight.createClient({
service: 'file:///badfile.json'
service: 'file:///badfile.json',
id: 'test_start_bad_file'
}, function(err) {

@@ -670,3 +831,4 @@ test.ok(err instanceof Error);

mqlight.createClient({
service: 'file://remote.example.com/badfile.json'
service: 'file://remote.example.com/badfile.json',
id: 'test_start_bad_remote_file_uri'
});

@@ -692,3 +854,4 @@ },

var client = mqlight.createClient({
service: 'file:///D:/test/path/file.json'
service: 'file:///D:/test/path/file.json',
id: 'test_start_windows_drive_letter_file_uri'
}, function(err) {

@@ -701,2 +864,4 @@ test.ifError(err);

'Incorrect filename passed: ' + filename);
var data = '{"service":' + JSON.stringify('amqp://host') + '}';
if (callback) callback(undefined, data);
client.stop();

@@ -730,3 +895,4 @@ test.done();

var client = mqlight.createClient({
service: 'file://localhost/badjson.json'
service: 'file://localhost/badjson.json',
id: 'test_start_file_bad_json'
}, function(err) {

@@ -745,3 +911,3 @@ test.ok(err instanceof Error);

* Tests that after successfully connecting to the server, a heartheat is
* setup to call pn_messeger_work at the rate required by
* setup to call pn_messenger_work at the rate required by
* the server.

@@ -757,3 +923,6 @@ *

});
var client = mqlight.createClient({service: 'amqp://host:1234'});
var client = mqlight.createClient({
service: 'amqp://host:1234',
id: 'test_start_heartbeat'
});
client.start(function() {

@@ -773,3 +942,3 @@ // Function to check for heartbeats. Invoked at half the rate of heartbeats

// is thrashing rather than an accurate attempt to count the expected
// heartbeats)
// heartbeats)
} else if (heartbeatCount / count > 10) {

@@ -807,2 +976,3 @@ client.stop();

service: 'amqp://host',
id: 'test_start_user_password_options.00',
user: undefined,

@@ -812,6 +982,6 @@ password: undefined,

expect_user: undefined,
expect_password: undefined
},
expect_password: undefined },
{ desc: '01: user specified as a property - but no password',
service: 'amqp://host',
id: 'test_start_user_password_options.01',
user: 'user',

@@ -822,2 +992,3 @@ password: undefined,

service: 'amqp://host',
id: 'test_start_user_password_options.02',
user: undefined,

@@ -828,2 +999,3 @@ password: 'password',

service: 'amqp://user@host',
id: 'test_start_user_password_options.03',
user: undefined,

@@ -834,2 +1006,3 @@ password: undefined,

service: 'amqp://user:pass@host',
id: 'test_start_user_password_options.04',
user: undefined,

@@ -839,6 +1012,6 @@ password: undefined,

expect_user: 'user',
expect_password: 'pass'
},
expect_password: 'pass' },
{ desc: '05: user/password in (String) URL, user mismatches properties',
service: 'amqp://user1:pass1@host',
id: 'test_start_user_password_options.05',
user: 'user2',

@@ -849,2 +1022,3 @@ password: 'pass1',

service: 'amqp://user1:pass1@host',
id: 'test_start_user_password_options.06',
user: 'user1',

@@ -855,2 +1029,3 @@ password: 'pass2',

service: 'amqp://user1:pass1@host',
id: 'test_start_user_password_options.07',
user: 'user1',

@@ -860,6 +1035,6 @@ password: 'pass1',

expect_user: 'user1',
expect_password: 'pass1'
},
expect_password: 'pass1' },
{ desc: '08: Array URLs have mixture of embedded auth #1',
service: ['amqp://user1:pass1@host', 'amqp://host'],
id: 'test_start_user_password_options.08',
user: undefined,

@@ -870,2 +1045,3 @@ password: undefined,

service: ['amqp://host', 'amqp://user1:pass1@host'],
id: 'test_start_user_password_options.09',
user: undefined,

@@ -876,2 +1052,3 @@ password: undefined,

service: ['amqp://user1:pass1@host', 'amqp://user1:pass2@host'],
id: 'test_start_user_password_options.10',
user: undefined,

@@ -882,2 +1059,3 @@ password: undefined,

service: ['amqp://user1:pass1@host', 'amqp://user2:pass1@host'],
id: 'test_start_user_password_options.11',
user: undefined,

@@ -888,2 +1066,3 @@ password: undefined,

service: ['amqp://user1:pass1@host', 'amqp://user1:pass1@host'],
id: 'test_start_user_password_options.12',
user: undefined,

@@ -893,6 +1072,6 @@ password: undefined,

expect_user: 'user1',
expect_password: 'pass1'
},
expect_password: 'pass1' },
{ desc: '13: Array URLs and properties all match',
service: ['amqp://user1:pass1@host', 'amqp://user1:pass1@host'],
id: 'test_start_user_password_options.13',
user: 'user1',

@@ -902,6 +1081,6 @@ password: 'pass1',

expect_user: 'user1',
expect_password: 'pass1'
},
expect_password: 'pass1' },
{ desc: '14: Array URLs have same values but user property different',
service: ['amqp://user1:pass1@host', 'amqp://user1:pass1@host'],
id: 'test_start_user_password_options.14',
user: 'user2',

@@ -912,2 +1091,3 @@ password: 'pass1',

service: ['amqp://user1:pass1@host', 'amqp://user1:pass1@host'],
id: 'test_start_user_password_options.15',
user: 'user1',

@@ -918,2 +1098,3 @@ password: 'pass2',

service: function(cb) {cb(undefined, 'amqp://user1:pass1@host');},
id: 'test_start_user_password_options.16',
user: undefined,

@@ -923,6 +1104,6 @@ password: undefined,

expect_user: 'user1',
expect_password: 'pass1'
},
expect_password: 'pass1' },
{ desc: '17: Func returns String without auth, user/pass props',
service: function(cb) {cb(undefined, 'amqp://host');},
id: 'test_start_user_password_options.17',
user: 'user1',

@@ -932,6 +1113,6 @@ password: 'pass1',

expect_user: 'user1',
expect_password: 'pass1'
},
expect_password: 'pass1' },
{ desc: '18: Func returns String with user/pass matches properties',
service: function(cb) {cb(undefined, 'amqp://user1:pass1@host');},
id: 'test_start_user_password_options.18',
user: 'user1',

@@ -941,6 +1122,6 @@ password: 'pass1',

expect_user: 'user1',
expect_password: 'pass1'
},
expect_password: 'pass1' },
{ desc: '19: Func returns URI with only user - no other values',
service: function(cb) {cb(undefined, 'amqp://user1@host');},
id: 'test_start_user_password_options.19',
user: undefined,

@@ -950,4 +1131,5 @@ password: undefined,

{ desc: '20: Func returns Array with different credentials in URLs #1',
service: function(cb)
{cb(undefined, ['amqp://host', 'amqp://user1:pass1@host']);},
service: function(cb) {
cb(undefined, ['amqp://host', 'amqp://user1:pass1@host']);},
id: 'test_start_user_password_options.20',
user: undefined,

@@ -957,4 +1139,5 @@ password: undefined,

{ desc: '21: Func returns Array with different credentials in URLs #2',
service: function(cb)
{cb(undefined, ['amqp://user1:pass1@host', 'amqp://host']);},
service: function(cb) {
cb(undefined, ['amqp://user1:pass1@host', 'amqp://host']);},
id: 'test_start_user_password_options.21',
user: undefined,

@@ -964,4 +1147,5 @@ password: undefined,

{ desc: '22: Func returns Array with users mismatching in URLs',
service: function(cb)
{cb(undefined, ['amqp://user1:pass1@host', 'amqp://user2:pass1@host']);},
service: function(cb) {
cb(undefined, ['amqp://user1:pass1@host', 'amqp://user2:pass1@host']);},
id: 'test_start_user_password_options.22',
user: undefined,

@@ -971,4 +1155,5 @@ password: undefined,

{ desc: '23: Func returns URLs that mismatch on password',
service: function(cb)
{cb(undefined, ['amqp://user1:pass1@host', 'amqp://user1:pass2@host']);},
service: function(cb) {
cb(undefined, ['amqp://user1:pass1@host', 'amqp://user1:pass2@host']);},
id: 'test_start_user_password_options.23',
user: undefined,

@@ -978,4 +1163,5 @@ password: undefined,

{ desc: '24: Func returns URLs that match each other but mismatch props',
service: function(cb)
{cb(undefined, ['amqp://user1:pass1@host', 'amqp://user1:pass1@host']);},
service: function(cb) {
cb(undefined, ['amqp://user1:pass1@host', 'amqp://user1:pass1@host']);},
id: 'test_start_user_password_options.24',
user: 'user2',

@@ -987,2 +1173,3 @@ password: 'pass1',

{cb(undefined, ['amqp://user1:pass1@host', 'amqp://user1:pass1@host']);},
id: 'test_start_user_password_options.25',
user: 'user1',

@@ -998,4 +1185,3 @@ password: 'pass1',

var lastUsr, lastPw;
mqlight.proton.messenger.connect = function(service, sslTrustCertificate,
sslVerifyName) {
mqlight.proton.messenger.connect = function(service) {
var auth;

@@ -1016,4 +1202,3 @@ try {

var messenger = stubproton.createProtonStub().createMessenger();
var result = messenger.connect.apply(messenger, [service,
sslTrustCertificate, sslVerifyName]);
var result = messenger.connect.apply(messenger, [service]);
return result;

@@ -1020,0 +1205,0 @@ };

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/teststop.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/teststop.js
*/
/*

@@ -39,3 +42,6 @@ * <copyright

module.exports.test_stop_callback_and_event = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_stop_callback_and_event'
});
client.start(function() {

@@ -71,3 +77,6 @@ var count = 0;

module.exports.test_listener_fired_on_subsequent_tick = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_listener_fired_on_subsequent_tick'
});
client.start();

@@ -89,3 +98,6 @@ client.on('started', function() {

module.exports.test_stop_argument_is_function = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_stop_argument_is_function'
});
test.throws(

@@ -98,2 +110,3 @@ function() {

);
client.stop();
test.done();

@@ -109,3 +122,6 @@ };

module.exports.test_stop_method_returns_client = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_stop_method_returns_client'
});
var result = client.stop();

@@ -143,2 +159,26 @@ test.ok(result === client);

/**
* Tests that when calling stop multiple times, all callbacks
* get invoked.
* @param {object} test the unittest interface
*/
module.exports.test_stop_all_callbacks_called = function(test) {
var count = 0;
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_start_all_callbacks_called'
});
var stopped = function(err) {
test.ok(!err);
count++;
if (count == 3) {
test.done();
}
};
client.stop(stopped);
client.stop(stopped);
client.stop(stopped);
};
/**
* Test that if too many arguments are supplied to stop - then they are

@@ -149,3 +189,6 @@ * ignored.

module.exports.test_stop_too_many_arguments = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_stop_too_many_arguments'
});
client.stop(function(err) {

@@ -165,3 +208,6 @@ test.ok(!err);

module.exports.test_stop_cleared_subscriptions = function(test) {
var client = mqlight.createClient({service: 'amqp://host'});
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_stop_cleared_subscriptions'
});
client.on('started', function() {

@@ -168,0 +214,0 @@ client.on('stopped', function() {

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/testsubscribe.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/testsubscribe.js
*/
/*

@@ -195,3 +198,3 @@ * <copyright

test.equals(arguments.length, 3);
test.deepEqual(arguments[0], undefined); // error argument
test.deepEqual(arguments[0], null); // error argument
test.deepEqual(arguments[1], '/foo'); // topic pattern

@@ -619,5 +622,5 @@ test.equals(arguments[2], undefined); // share name

var savedSubscribe = mqlight.proton.messenger.subscribe;
var subscribedCredit = -1;
mqlight.proton.messenger.subscribe = function(address, qos, ttl, credit) {
var savedFlow = mqlight.proton.messenger.flow;
var subscribedCredit;
mqlight.proton.messenger.flow = function(address, credit) {
subscribedCredit = credit;

@@ -627,22 +630,37 @@ };

service: 'amqp://host'});
var runTests = function(i) {
if (i === data.length) {
mqlight.proton.messenger.flow = savedFlow;
client.stop(function() {
test.done();
});
return;
}
subscribedCredit = 0;
if (data[i].expected !== undefined) {
test.doesNotThrow(function() {
client.subscribe('testpattern' + i,
data[i].credit !== undefined ? data[i] : {},
function() {
test.deepEqual(subscribedCredit, data[i].expected,
'wrong value passed to proton messenger - test ' +
'data index: ' + i + ' expected: ' +
data[i].expected + ' actual : ' +
subscribedCredit);
runTests(i + 1);
}
);
}, undefined, 'test data index: ' + i);
} else {
test.throws(function() {
client.subscribe('testpattern', data[i]);
}, RangeError, 'test data index: ' + i);
runTests(i + 1);
}
};
client.on('started', function() {
for (var i = 0; i < data.length; ++i) {
if (data[i].expected !== undefined) {
test.doesNotThrow(function() {
client.subscribe('testpattern' + i,
data[i].credit !== undefined ? data[i] : {});
}, undefined, 'test data index: ' + i);
test.deepEqual(subscribedCredit, data[i].expected,
'wrong value passed to proton messenger - test data index: ' + i +
' expected: ' + data[i].expected + ' actual : ' + subscribedCredit);
} else {
test.throws(function() {
client.subscribe('testpattern', data[i]);
}, RangeError, 'test data index: ' + i);
}
}
mqlight.proton.messenger.subscribe = savedSubscribe;
client.stop(function() {
test.done();
});
runTests(0);
});

@@ -659,6 +677,6 @@ };

*/
module.exports.test_client_replaced = function(test) {
module.exports.test_subscribe_client_replaced = function(test) {
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_client_replaced'
id: 'test_subscribe_client_replaced'
});

@@ -685,2 +703,3 @@

mqlight.proton.messenger.subscribe = savedSubscribeFunction;
client.stop();
test.done();

@@ -691,1 +710,24 @@ });

/**
* Test that an attempt to subscribe twice results in a
* SubscribedError being thrown.
*
* @param {object} test the unittest interface
*/
module.exports.test_subscribe_client_twice = function(test) {
var client = mqlight.createClient({
service: 'amqp://host',
id: 'test_subscribe_client_twice'
}, function(err) {
test.ok(!err);
client.subscribe('topic', function(err) {
test.ok(!err);
test.throws(function () {
client.subscribe('topic');
}, mqlight.SubscribedError);
client.stop();
test.done();
});
});
};

@@ -1,2 +0,5 @@

/* @(#) MQMBID sn=p800-L141110.2 su=_pMlgsGkYEeS1dc-bnD4A1g pn=appmsging/nodejs/mqlight/test/testunsubscribe.js */
/* @(#) MQMBID sn=pkoa-L150217
su=_XHkTarY4EeS2tKt4Znd7Ug
pn=appmsging/nodejs/mqlight/test/testunsubscribe.js
*/
/*

@@ -64,8 +67,9 @@ * <copyright

test.doesNotThrow(function() {
client.subscribe('/foo', 'share1');
client.unsubscribe('/foo', 'share1', {}, function() {}, 'stowaway');
client.subscribe('/foo', 'share1', function() {
client.unsubscribe('/foo', 'share1', {}, function() {}, 'stowaway');
client.stop(function() {
test.done();
});
});
});
client.stop(function() {
test.done();
});
});

@@ -88,20 +92,21 @@ };

test.throws(function() {
client.subscribe('/foo1', 'share');
client.unsubscribe('/foo1', 'share', {}, 7);
}, TypeError);
test.doesNotThrow(function() {
client.subscribe('/foo2');
client.unsubscribe('/foo2', function() {});
client.subscribe('/foo2', function() {
client.unsubscribe('/foo2', function() {
client.subscribe('/foo3', 'share', function() {
client.unsubscribe('/foo3', 'share', function() {
client.subscribe('/foo4', 'share', function() {
client.unsubscribe('/foo4', 'share', {}, function() {
client.stop(function() {
test.done();
});
});
});
});
});
});
});
});
test.doesNotThrow(function() {
client.subscribe('/foo3', 'share');
client.unsubscribe('/foo3', 'share', function() {});
});
test.doesNotThrow(function() {
client.subscribe('/foo4', 'share');
client.unsubscribe('/foo4', 'share', {}, function() {});
});
client.stop(function() {
test.done();
});
});

@@ -120,2 +125,3 @@ };

module.exports.test_unsubscribe_parameters = function(test) {
var client;
var service = 'amqp://host:5672';

@@ -130,2 +136,3 @@ var pattern = '/pattern';

var object = {};
var testNum = 0;

@@ -135,16 +142,17 @@ // Data to drive the test with. 'args' is the argument list to pass into

// indicate the expected interpretation of 'args'.
var data = [{args: [pattern]},
{args: [pattern, cb], callback: cb},
{args: [pattern, share], share: share},
{args: [pattern, object], object: object},
{args: [pattern, share, cb], share: share, callback: cb},
{args: [pattern, object, cb], object: object, callback: cb},
{args: [pattern, share, object], share: share, object: object},
{args: [pattern, 7], share: 7},
{args: [pattern, 'boo'], share: 'boo'},
{args: [pattern, {}], object: {}},
{args: [pattern, 7, cb], share: 7, callback: cb},
{args: [pattern, {}, cb], object: {}, callback: cb},
{args: [pattern, [], []], share: [], object: []},
{args: [pattern, share, object, cb],
var data = [{args: [pattern + '0']},
{args: [pattern + '1', cb], callback: cb},
{args: [pattern + '2', share], share: share},
{args: [pattern + '3', object], object: object},
{args: [pattern + '4', share, cb], share: share, callback: cb},
{args: [pattern + '5', object, cb], object: object, callback: cb},
{args: [pattern + '6', share, object],
share: share, object: object},
{args: [pattern + '7', 7], share: 7},
{args: [pattern + '8', 'boo'], share: 'boo'},
{args: [pattern + '9', {}], object: {}},
{args: [pattern + '10', 7, cb], share: 7, callback: cb},
{args: [pattern + '11', {}, cb], object: {}, callback: cb},
{args: [pattern + '12', [], []], share: [], object: []},
{args: [pattern + '13', share, object, cb],
share: share, object: object, callback: cb}];

@@ -164,27 +172,38 @@

lastUnsubscribedAddress = address;
};
var client = mqlight.createClient({
id: 'test_unsubscribe_parameters',
service: service
}, function() {
for (var i = 0; i < data.length; ++i) {
var clientUnsubscribeMethod = client.unsubscribe;
var clientSubscribeMethod = client.subscribe;
lastUnsubscribedAddress = undefined;
clientSubscribeMethod.apply(client, data[i].args);
clientUnsubscribeMethod.apply(client, data[i].args);
var expectedAddress =
service + '/' +
((data[testNum].share) ?
('share:' + data[testNum].share + ':') : 'private:') +
pattern + testNum;
var expectedAddress =
service + '/' +
((data[i].share) ? ('share:' + data[i].share + ':') : 'private:') +
pattern;
test.deepEqual(lastUnsubscribedAddress, expectedAddress);
test.deepEqual(lastUnsubscribedAddress, expectedAddress);
if(testNum < data.length - 1) {
process.nextTick(function() {
runTests(++testNum);
});
} else {
// Restore the saved messenger unsubscribe implementation
mqlight.proton.messenger.unsubscribe = savedUnsubscribe;
client.stop();
}
};
// Restore the saved messenger unsubscribe implementation
mqlight.proton.messenger.unsubscribe = savedUnsubscribe;
client.stop();
var runTests = function(i) {
var clientUnsubscribeMethod = client.unsubscribe;
var clientSubscribeMethod = client.subscribe;
lastUnsubscribedAddress = undefined;
clientSubscribeMethod.apply(client, [pattern + i,
('share' in data[i]) ? data[i].args[1] : undefined, {}, function() {
clientUnsubscribeMethod.apply(client, data[i].args);
}]
);
};
client = mqlight.createClient({
id: 'test_unsubscribe_parameters',
service: service
}, function() {
runTests(testNum);
});

@@ -196,3 +215,3 @@

var testIsDone = function() {
if (currentCallbackInvocations === 2*expectedCallbackInvocations) {
if (currentCallbackInvocations === expectedCallbackInvocations) {
test.done();

@@ -220,17 +239,19 @@ } else {

client.on('started', function() {
client.subscribe('/foo');
client.unsubscribe('/foo', function() {
test.equals(arguments.length, 3);
test.deepEqual(arguments[0], null); // error argument
test.deepEqual(arguments[1], '/foo'); // topic pattern argument
test.deepEqual(arguments[2], undefined); // share argument
test.ok(this === client);
client.subscribe('/foo2', 'share');
client.unsubscribe('/foo2', 'share', function() {
client.subscribe('/foo', function() {
client.unsubscribe('/foo', function() {
test.equals(arguments.length, 3);
test.deepEqual(arguments[0], null); // error argument
test.deepEqual(arguments[1], '/foo2'); // topic pattern argument
test.deepEqual(arguments[2], 'share'); // share argument
test.deepEqual(arguments[1], '/foo'); // topic pattern argument
test.deepEqual(arguments[2], undefined); // share argument
test.ok(this === client);
client.stop();
client.subscribe('/foo2', 'share', function() {
client.unsubscribe('/foo2', 'share', function() {
test.equals(arguments.length, 3);
test.deepEqual(arguments[0], null); // error argument
test.deepEqual(arguments[1], '/foo2'); // topic pattern argument
test.deepEqual(arguments[2], 'share'); // share argument
test.ok(this === client);
client.stop();
});
});
});

@@ -291,6 +312,7 @@ });

function() {
client.subscribe('/foo');
test.deepEqual(client.unsubscribe('/foo'), client);
client.stop(function(){
test.done();
client.subscribe('/foo', function() {
test.deepEqual(client.unsubscribe('/foo'), client);
client.stop(function(){
test.done();
});
});

@@ -320,19 +342,30 @@ });

var client = mqlight.createClient({id: 'test_unsubscribe_topics', service:
'amqp://host'},
function() {
for (var i = 0; i < data.length; ++i) {
if (data[i].valid) {
test.doesNotThrow(function() {
client.subscribe(data[i].pattern);
client.unsubscribe(data[i].pattern);
'amqp://host'});
var runTests = function (i) {
if (i === data.length) {
client.stop(function(){
test.done();
});
return;
}
if (data[i].valid) {
test.doesNotThrow(function() {
client.subscribe(data[i].pattern, function() {
client.unsubscribe(data[i].pattern, function() {
runTests(i + 1);
});
});
} else {
test.throws(function() {
client.unsubscribe(data[i].pattern);
}, TypeError, 'pattern should have been rejected: ' + data[i].pattern);
}
});
} else {
test.throws(function() {
client.unsubscribe(data[i].pattern);
}, TypeError, 'pattern should have been rejected: ' + data[i].pattern);
runTests(i + 1);
}
client.stop(function(){
test.done();
});
};
client.once('started', function() {
runTests(0);
});

@@ -358,18 +391,29 @@ };

});
client.on('started', function() {
for (var i = 0; i < data.length; ++i) {
if (data[i].valid) {
test.doesNotThrow(function() {
client.subscribe('/foo', data[i].share);
client.unsubscribe('/foo', data[i].share);
var runTests = function(i) {
if (i === data.length) {
client.stop(function() {
test.done();
});
return;
}
if (data[i].valid) {
test.doesNotThrow(function() {
client.subscribe('/foo', data[i].share, function() {
client.unsubscribe('/foo', data[i].share, function() {
runTests(i + 1);
});
});
} else {
test.throws(function() {
client.unsubscribe('/foo', data[i].share);
}, mqlight.InvalidArgumentError, i);
}
});
} else {
test.throws(function() {
client.unsubscribe('/foo', data[i].share);
}, mqlight.InvalidArgumentError, i);
runTests(i + 1);
}
client.stop(function() {
test.done();
});
};
client.on('started', function() {
runTests(0);
});

@@ -402,26 +446,37 @@ };

'amqp://host'});
client.on('started', function() {
for (var i = 0; i < data.length; ++i) {
if (data[i].valid) {
test.doesNotThrow(
function() {
client.subscribe('testpattern', 'share');
var runTests = function(i) {
if (i === data.length) {
client.stop(function() {
test.done();
});
return;
}
if (data[i].valid) {
test.doesNotThrow(
function() {
client.subscribe('testpattern', 'share', function() {
client.unsubscribe('testpattern', 'share', data[i].options,
function() {});
}
);
} else {
test.throws(
function() {
client.unsubscribe('testpattern', 'share', data[i].options,
function() {});
},
TypeError,
'options should have been rejected: ' + data[i].options
);
}
function() {
runTests(i + 1);
});
});
}
);
} else {
test.throws(
function() {
client.unsubscribe('testpattern', 'share', data[i].options,
function() {});
},
TypeError,
'options should have been rejected: ' + data[i].options
);
runTests(i + 1);
}
client.stop(function() {
test.done();
});
};
client.on('started', function() {
runTests(0);
});

@@ -456,20 +511,31 @@ };

service: 'amqp://host'});
client.on('started', function() {
for (var i = 0; i < data.length; ++i) {
var opts = { ttl: data[i].ttl };
if (data[i].valid) {
test.doesNotThrow(function() {
client.subscribe('testpattern');
client.unsubscribe('testpattern', opts);
var runTests = function(i) {
if (i === data.length) {
client.stop(function() {
test.done();
});
return;
}
var opts = { ttl: data[i].ttl };
if (data[i].valid) {
test.doesNotThrow(function() {
client.subscribe('testpattern', function() {
client.unsubscribe('testpattern', opts, function() {
runTests(i + 1);
});
});
} else {
test.throws(function() {
client.unsubscribe('testpattern', opts);
}, RangeError, 'ttl should have been rejected: ' + data[i].ttl);
}
});
} else {
test.throws(function() {
client.unsubscribe('testpattern', opts);
}, RangeError, 'ttl should have been rejected: ' + data[i].ttl);
runTests(i + 1);
}
client.stop(function() {
test.done();
});
};
client.on('started', function() {
runTests(0);
});
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc