File messages

When you publish or subscribe to files as a part of an automated test, the file transport can be used like a message source from a queue, topic, or other endpoint. A publisher can use HCL OneTest API message formatters to write XML, SOAP, File schema, or other formats to disk. A subscriber can follow the same mechanism to validate content and format when reading.

The standard field options (filtering, validation, tag storage) are available when you are publishing or subscribing with the file transport. For more information, see HCL OneTest™ API reference.

Publish

You can use the file transport in a publish action to write data to a file.

After you specify the transport, select the formatter to be used, as follows:

  • Byte Array - used for fields that contain non-encoded strings
  • IATA - used for fields that contain IATA codes
  • Text - used for text-based fields

You can override the file name pattern that is defined in the transport under File Name Pattern Override, and tags can be used to select the file name pattern location and name dynamically.

Note: If the override is a simple file name, it's resolved relative to the directory from the transport. If the override contains a directory (or directories), it overrides the entire path, including the directory from the transport.

The following options can be enabled or disabled when you are writing to a file by using the publish action.

  • Create can create the specified file if it does not currently exist.
  • Append leaves existing file contents intact and appends new data to the end of the file when you are writing.
    Note: Appending to a file is only supported for files on the local file system. Attempts to append to a remote file will fail.
  • New Line appends new line characters to the end of the file after it is written, by using the New Line option that is specified in the transport.
  • Close explicitly closes the file after it is written, releasing the file handle between test iterations. If left unchecked, the file is closed only at the end of the test.

Subscribe

You can use the file transport in a subscribe action to read data from a file.

After you specify the transport, select the formatter to be used, as follows:

  • Byte Array - used for fields that contain non-encoded strings
  • IATA - used for fields that contain IATA codes
  • Text - used for text-based fields

You can override the file name pattern that is defined in the transport under File Name Pattern Override, and tags can be used to select the file name pattern location and name dynamically.

  • Polling Interval is the interval, in seconds, that the file system is queried. The default value is 10.
  • If Ignore Existing Files is selected, files that exist when the first poll occurs will be ignored.
  • If Delete files after successful processing is selected, files whole content has been matched and validated successfully will be deleted once processing of the file completes. Where multiple messages are consumed from a file, all messages must be successfully validated for deletion to occur. When consuming a file within a test, if the test fails, deletion does not occur.

Timeout and Tolerance control the amount of time allowed in attempts to read the file.

  • Under Timeout, enter the amount of time (in milliseconds) after which the test action fails if HCL OneTest API is unable to read from the file.
  • Under Tolerance, set the amount of time (in milliseconds) that HCL OneTest™ API allows after the timeout, to continue to check for the file. If the file becomes available after the timeout and before timeout + tolerance, the test action failure will indicate that the file was late.
Note: You can validate an empty file (that is, one that contains zero bytes) by selecting the Byte Array formatter and leaving the data (ByteArray) field empty.
Feedback