Using Java™ objects in messages
Once you add a JAR file to HCL OneTest™ API, it can be applied as a schema to messages in applicable test actions. An example illustrates how to apply an existing Java™ object schema to a message.
About this task
To use Java™ objects in messages, follow these steps:
Procedure
- Create a test in an operation that contains a reference to your JMS provider.
- Add a Publish action followed by a Subscribe action to the Test Steps phase of the test.
- Double-click the Publish action to open it for editing.
- Select your JMS-based transport and formatter,
and select Object Message in the Message
Type field (above the message body).
- In the message area, right-click the Object (Message) element and select from the menu.
- When prompted whether to retain the content of the existing message body, select No, overwrite content.
- Right-click the object (pojo) element
and select Schema from the menu.
- In the Schema Selector window, Schema Type field, click .
- In the pane below the Schema Type, select the schema that
contains the object to apply to the message.This schema is in the JAR file that was imported into the HCL OneTest™ API Schema Library.
- No Formatter Properties are used with Java™ objects.
-
In the Content Options section, select or clear the following options as needed:
- Retain existing content
- Select this option to apply a schema or expand a field without losing the original data. If the attempt to use the original data fails, the data is displayed with red Xs. If you clear this option, data is cleared before the new schema is applied. In cases where the data is assumed to be retained, this option is not displayed.
- Include Text nodes
- Select this option to generate Text nodes with the message.
- Include optional nodes
- If the schema includes optional fields, select this option to add them to the message.
Before HCL OneTest™ API version 8.7, additional options were displayed when you applied a schema to a message:- Accept fields in any order
- Ignore missing fields in received message
- Ignore additional fields in received message
- Enable validation of time-based fields
These options can be set in the project preferences. Click
. - The schema is applied to the original message, and the valid members that are defined in the JAR file are displayed as message fields.
- The same steps can be carried out in the Subscribe action to apply validation options.