Pub/Sub Test Suite Spec

Overview

Every integration test suite should be configurable and load pub/sub API keys and the URL dynamically from a test-config.json, .properties file, or a file related to that language as long as that file is in the .gitignore. Whatever approach chosen make sure it is described in the README.md

Unit Tests

Parsing expected responses tests

All of the expected responses should be correctly transformed into their appropriate object definitions (if applicable).

Integration Tests

Full Sweep Test

This should test all functionality of pub/sub with a single client. The client should send at least one message and test the following functionality : subscribe, publish, the receiving messages handlers, list subscriptions, unsubscribing, and closing the socket cleanly. 

Interaction Test

This should test publish/subscribe functionality of pub/sub with two clients. Each client should send at least one message to the other and test that the messages are received on the correct clients only.

Reconnect Test

This should test the following SDK features:

  • auto-reconnect (reconnect with exponential back-off)
  • session restore (subscriptions retained for 5 minutes, and resumed on reconnect)

PublishWithAck Test

This should test to make sure the publishWithAck() method is working correctly (notified in the event of success or failure (permissions)).

GetSessionUuid Test

This should test that the getSessionUuid() method is working correctly. Should connect, get session UUID, close the connection, and then reconnect with the provided UUID, run the getSessionUuid again, and verify the UUID has not changed.

Event Handler Test

onRawRecord - Verify this receives anything returned from the server: this should include acks for publishes, messages from subscriptions, subscription success acks, 

onMessage - Verify this receives only messages from all subscribed channels, this should not receive any ack messages

onError - Cannot be tested via integration tests.

onErrorResponse - Attempt to subscribe to a channel when the client does not have read permissions, attempt to publish without write permissions.

onReconnect - Verify the reconnection emits an event. Utilize the dropConnection function to accomplish this.

onClose - Verify that the socket close emits a close event.

onNewSession - Set reconnect to false, make a connection with the pub/sub SDK, and then close the socket. Using the same connection instance, connect again and provide an unused UUID and verify that this event is emitted.