Read a File (Disk URL or Classpath)

The Read a File (Disk, URL, or Classpath) step reads a file from your file system, a URL, or the classpath.
dts103
The Read a File (Disk, URL, or Classpath) step reads a file from your file system, a URL, or the classpath.
Files are used as a source of data for testing. This step can be paired with the Load a set of File Names data set to provide source data for testing.
You can read a text file or a binary file. The contents of the file can optionally be stored in a property.
Complete the following fields:
  • File
    Enter the path name, a URL, or a classpath, or browse to the file using the
    Browse
    button.
  • File Encoding
    Accept the default encoding of UTF-8 or select an alternate encoding from the drop-down list. You can also select
    Auto-detect
    and click
    Detect
    to have 
    DevTest
    select an encoding type for you. If you select
    Platform Default
    ,
    the JVM chooses an encoding, which can change across machines and even across JVMs on the same machine.
    We recommend that you select a specific character encoding, such as
    UTF-8
  • Property Key
    Enter the name of the property in which to store the file contents (optional).
  • Load as Byte []
    To load contents as a byte array, select this check box. This capability is useful when loading a file to be used as a binaryData type in a web service execution parameter.
  • Cache file in memory
    To avoid memory leaks, adjust the size and time duration to specify when the cache is flushed.
    The maximum file size has a default of 20 MB, but you can adjust the size with the
    FileNode.cache.max.size.mb
    property.
    If a cached entry is inactive for 30 minutes, that entry is removed from cache. The default is 30 minutes but you can adjust the
    FileNode.cache.duration.mins
    to change the time.
  • If environment error
    Select the step to redirect to if the Read a File test fails.
  • Display as characters
    The contents are displayed as hexadecimal encoded bytes unless you select this check box. This check box is only visible if the
    Load as Byte []
    box is selected.
Click
Load
to load and display the file. The content is now ready for you to filter and add assertions.
If a binary file is loaded but you do not select to load as byte,
DevTest
converts the data to characters (many of which are unreadable) and the step response is a string.
The Read a File step has a default name using this convention:
Read file [set the File Name variable]
.
If another step uses the default step name,
DevTest
appends a number to this step name to keep it unique. You can change step names at any time.