
Title
Page icon
Create new category
Edit page index title
Edit category
Edit link
Websockets
Required config
To test a websocket API you need to add the <websockets> config block to the integrations.xml file located in the config folder.
This configuration requires the following parameters:
1. alias - alias for this config to be used in test scenarios (must be unique) 2. URL - URL of your resource to connect to 3. protocol - specifies the WebSocket protocol of this API (can be "standard" or "stomp") 4. enabled - flag to enable/disable this config (can be "true" or "false")
Testing the Standard websocket API:
To interact with a websocket you need to set: the main (parent) command in which all commands are executed, the disconnect argument which specifies whether to disconnect the connection after closing the main tag (default disconnect="true"), the alias argument which is the same as in websocket integration config.
Inside main command <websocket>...</websocket> command you can use commands:
Receive command is used to checking the receipt of messages from the server. The command has arguments:
comment - whichused to comment your command
maxRecords- limiter of messages you want to compare
timeoutMillis- the maximum time to wait before receiving a message, specified in milliseconds
<message>[]</message>- message that you will get from server or File where will be message that you will get from server<file>expected_25.json</file>
Send command you use to send message to server. The command has arguments:
comment- which is used to comment your command
<message></message>- message that you will send to server or File where will send message what you will get from server expected_35.json
Sample script for testing websockets:
Testing the websocket API with Stomp protocol:
To interact with a websocket - The main (parent) command in which all commands are executed, The disconnect argument specifies whether to disconnect the connection after closing the main tag (default disconnect="true") The alias argument is the same as in websocket integration config.
If the resource you want to test uses the Stomp protocol, all commands inside the <websocket>...</websocket> command must be placed in the <stomp>...</stomp> subcommand, after it you can use the following commands:
Subscribe is used to subscribe to a specific topic from which you want to receive messages. The command has arguments:
comment- which used to comment your command
topic- here you specify the topic from which you want to receive messages
Receive command is used to check the receipt of messages from the server. The command has arguments:
comment- is used to comment your command
topic- here you specify the topic from which you want to receive messages
count - indicatesthe number of first messages that you want to compare
timeoutMillis- the maximum time to wait before receiving a message, specified in milliseconds
<message>[]</message>- message that you will get from server or File where will be message that you will get from server<file>expected_28.json</file>
Send command you use to send message to server. The command has arguments:
comment- is used to comment your command
endpoint- here you specify the endpoint where you want to send messages
<message>[]</message>- message that you will send to server or File where will send massage what you will get from server expected_35.json
Sample script for testing websockets of the resource that use stomp protocol:
Copyright © Knubisoft