You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Overview

The asynchronous socket transport is built on top of Netty and provides a number of different modes.

Installation

The tool can be installed from the UI or command line.

UI Installation

  1. Go to Parasoft > Preferences and click System Properties.
  2. Click Add JARs and choose the com.parasoft.soavirt.transport.asynchronous.socket-1.2.0.jar file. Once this jar file is added to the SOAtest classpath, all of the required dependencies will be loaded.
  3. Click Apply.
  4. Restart SOAtest.

Command Line Installation

Add the com.parasoft.soavirt.transport.asynchronous.socket-1.2.0.jar file to the system.properties.classpath property in your settings properties file. For example:

system.properties.classpath=<path to jar>/com.parasoft.soavirt.transport.asynchronous.socket-1.2.0.jar 

Once the classpath is modified, all of the required dependencies will be loaded.

Usage

The asynchronous socket transport is primarily used in Messaging Client tools. The transport is configured in the messaging client's Transport tab. Choose Asynchronous Socket from the Transport menu and configure the available options.

Configuration

You can configure the following options.

Connection

Protocol

Specifies the protocol used to transmit messages. Options are TCP or UDP.

Default: TCP

Host

Specifies the host where the application is running. You can specify a fixed value or programmatically specify the host by choosing Scripted and clicking Edit Script to access the script editor. See Extensibility and Scripting Basics for additional information.

Default: localhost 

PortSpecifies the port on the host where the client will send messages. You can specify a fixed value or programmatically specify the port number by choosing Scripted and clicking Edit Script to access the script editor. See Extensibility and Scripting Basics for additional information.
Local Port

Specifies a local port if one must be used when making outbound connections. When blank (set to 0), the port is automatically assigned.

Default: 0

Character Set

Specifies the character set used for encoding messages. You can specify a fixed value or programmatically specify the character set by choosing Scripted and clicking Edit Script to access the script editor. See Extensibility and Scripting Basics for additional information.

Default: UTF-8 

Read Mode

Specifies the mode for reading messages.

  • Specify fixed for fixed length messages that are always the same size.
  • Specify prefixed for messages that have an int (4 bytes) length prefix at the beginning of the message.
  • Specify prefixed-full for messages that read the bytes from the socket and return the entire message (including prefix, and length field) in a hex string format.
  • Specify prefixed-string for messages with a series of string digits prefixing the message.
  • Specify token for messages that are delimited by an end character or unicode sequence.
  • Specify none to configure the tool to continue immediately without waiting to read the next message from the server.

You can specify a fixed value or programmatically specify the read mode by choosing Scripted and clicking Edit Script to access the script editor. See Extensibility and Scripting Basics for additional information.

Default: prefixed 

Format

Specifies how the request and response bytes are interpreted. Options are hex-string or byte-array.

Setting the format to byte-array will read and send the bytes as is. Payloads defined in the client’s text editor will be converted into bytes using the configured character set. File inputs will be read as bytes and sent as is.

Setting the format to hex-string will convert both the request and response to hex-encoded strings. In this format, the payload defined in the client should also be provided as a hex-string, which will then be sent as bytes. This format is useful for handling messages with non-printable ASCII characters, as it allows them to be represented as readable hex values (for example, 0A1F03).

Default: byte-array

Fixed Length

Specify the size of the fixed message in the Fixed Length field.

For example, if the size of messages is always four bytes, a client might send the following request:

[0, 0, 0, 0] 

The transport would send back a response of the same size, for example:

[1, 1, 1, 1] 

Each 4-byte message from the client would be considered a message.

Token Delimited

Token Delimiter

Specifies the token that delimits messages.

Default: byte "23", End-Of-Transmission-Block 

Token Type

Specifies the type of conversion used to get bytes from the token.

  • Specify string and the transport will use getBytes with the configured character set to convert to bytes.
  • Specify hex and the string will be parsed as a sequence of hexadecimal values. For example, 0a 0d would be the bytes 10 13.
  • Specify byte and the transport will parse the string as a sequence of bytes in decimal values separated by spaces, e.g., 10 13.

Default: hex 

Prefixed Variable-Length (Number)

The settings in this section only apply if the read mode is set to prefixed

Length of the Length Field

Determines the length of the length field. The desired number of bytes will be read and converted to a number to determine the length of the message. You can specify the following values: 1 , 2 , 3 , 4 , or 8.

The default is to read 4 bytes and convert it to an integer.

Include Length Field Size in Length 

Indicates if the length read should also include the length field size.

For example, if the option is enabled, a 4-byte message would send a length value of 8. This is because the default length of the length field is 4 bytes and will be added to the message body length. 

Default: true

Format of Static Prefix/Suffix 

Specifies the type of conversion used to convert the static prefix/suffix into bytes.

  • Specify string and the socket will use getBytes with the configured character set to convert to bytes.
  • Specify hex and the string will be parsed as a sequence of hexadecimal values. For example, 0a 0d would be the bytes 10 13.
  • Specify byte and the socket will parse the string as a sequence of bytes in decimal values separated by spaces, for example, 10 13.

Default: hex 

Static Prefix

Specifies a prefix segment to be added to the message that may be required. If specified, the message format will be <PREFIX_BYTES><LENGTH_FIELD_BYTES><MESSAGE_DATA_BYTES>.

Static Suffix

Specifies a suffix segment to be added to the message that may be required. If specified, the message format will be <LENGTH_FIELD_BYTES><MESSAGE_DATA_BYTES><SUFFIX_BYTES>.

Prefixed Variable-Length (Number) Configuration Example

If the client sends a request containing request1 that was prefixed with an int using the character set CP037 and the length includes the prefix length, then the request would be represented by the following bytes:

[0, 0, 0, 12, 114, 101, 113, 117, 101, 115, 116, 49]

The first four bytes ([0, 0, 0, 12]) are the integer 12, which is the length of the entire message including the first 4 bytes of the prefix. The remaining bytes are the string request1 as encoded by the configured character set.

Prefixed Variable-Length (Full)

The settings in this section only apply if the read mode is set to prefixed-full.

Length of the Length Field

Determines the length of the length field. The desired number of bytes will be read and converted to a number to determine the length of the message. You can specify the following values: 1 , 2 , 3 , 4 , or 8.

The default is to read 4 bytes and convert it to an integer.

Include Length Field Size in Length

Indicates if the length read should also include the length field size.

For example, if the option is enabled, a 4-byte message would send a length value of 8. This is because the default length of the length field is 4 bytes and will be added to the message body length. 

Default: true

Offset of Length Field

Specifies the amount to offset to reach the Length field if it is not the first byte of the message.

Default: 0

Include Offset in Length

Indicates whether the length should include the offset.

Default: true

Prefixed Variable-Length (Full) Configuration Example

This is an example of a message you might set when using the prefixed-full read mode and hex-string format:

99119911000e1111111122222222 

In this message, there is a prefix of four bytes (converted to eight characters in hex):

99119911 

The length of the message is two bytes (converted to four characters in hex):

000e 

And the message body is:

1111111122222222 

Prefixed Variable-Length (String)

The settings in this section only apply if the read mode is set to prefixed-string.

String Prefix LengthSpecifies the size of the message length prefix. The number of bytes to read is calculated based on the number of digits converted into bytes. The transport encodes 0 into bytes and multiplies the number by the number provided in this field.
Include Prefix in Length

Indicates if the length read from the prefix should also include the length of the prefix.

Default: true

SSL

Set SSL Enabled to true to listen over SSL. 

Logging

Specify the Log Level field. This setting is optional.

  • Enter 1 to only log errors.
  • Enter 2 to log errors and warnings.
  • Enter 3 to log errors, warnings, and info.
  • Enter 4 to log errors, warnings, info, and debug.

Default is 3 

Connection Management

You can enable the Keep connection alive in order to not miss any messages sent by the server in between tests or Close connection after test execution so the next test does not pick up old messages.

Testing Asynchronous Messages

Typically, this transport is used in a SOAtest messaging client to send one message as configured in the request tab and then wait to receive one message in response. However, sometimes a server may reply with multiple messages or even none at all. In these asynchronous cases use one or more of the following configurations (as applicable):

  • Send one message without waiting to receive a message from the server in reply by setting the Read Mode to none.
  • Skip sending a message and simply wait to receive the next message from the server by setting the Request tab to Literal, enabling Text, and leaving the text field empty.
  • Enable Keep connection alive in Connection Management to avoid missing any messages sent by the server in between tests.
  • Use Test Suite Flow Logic to loop through reading a dynamic number of messages from the server.

Change Log

1.2

  • Added support for the Prefixed Variable-Length (Full) read mode

1.1

  • Added support for UDP.

1.0

  • Initial release.
  • No labels