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

  1. Create a test in an operation that contains a reference to your JMS provider.
  2. Add a Publish action followed by a Subscribe action to the Test Steps phase of the test.
  3. Double-click the Publish action to open it for editing.
  4. Select your JMS-based transport and formatter, and select Object Message in the Message Type field (above the message body).
    The Message Type field is at the bottom of the screen capture.
  5. In the message area, right-click the Object (Message) element and select Root > Object from the menu.
  6. When prompted whether to retain the content of the existing message body, select No, overwrite content.
  7. Right-click the object (pojo) element and select Schema from the menu.
    The Object Message type
  8. In the Schema Selector window, Schema Type field, click Objects > Java Objects.
  9. 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.
  10. No Formatter Properties are used with Java objects.
  11. 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 Project > Preferences > Message.

  12. The schema is applied to the original message, and the valid members that are defined in the JAR file are displayed as message fields.
  13. The same steps can be carried out in the Subscribe action to apply validation options.
Feedback