Options for scripting

You can write scripts in Rational® Integration Tester by using legacy functions, ECMAScript (such as JavaScript), or a third-party scripting language that you install.
Rational Integration Tester provides a number of opportunities for dynamic user interaction, including:
The following topics and sections discuss aspects of these scripting languages:

Add other scripting languages

In addition to ECMAScript, you can customize Rational Integration Tester to use other scripting languages. The language must provide a .jar archive that implements the Java Scripting API and that you can embed in the product. For more information about the Java Scripting API, see the Java Scripting Programmer's Guide.

For example, to add Groovy script to Rational Integration Tester, complete the following steps:
  1. From the Groovy website (http://groovy.codehaus.org/), download the latest stable release.
  2. Extract the archive file to a local directory.
  3. Copy the groovy-1.8.6\embeddable\groovy-all-x.x.x.jar file into the Rational Integration Tester installation directory:
    rit_installation_directory/jre/lib/ext/
  4. Restart Rational Integration Tester.
  5. Groovy appears as an option in the drop-down menu for the Function.
Note: An agent that runs stubs that include Groovy scripts must have the Groovy .jar file on its class path; otherwise the agent throws a null pointer exception.

Convert legacy functions to ECMAScript

The following rules apply when converting functions to ECMAScript:
  • All strings must be enclosed in quotation marks, with appropriate escape sequences:
    • Quotation marks within the value of the string must be preceded by a backslash (\")
    • Backslashes must be preceded by another backslash (\\)
    Example legacy function:
    setTag(testFileName, C:\myfile.txt)
    After conversion to ECMAScript:
    setTag("testFileName", "C:\\myfile.txt")
  • Replace the null() function with the null keyword.
    Example legacy function:
    setTag(testTag, null())
    After conversion to ECMAScript:
    setTag(testTag, null)
  • Although the setTag() function is still valid in ECMAScript, you can assign values directly instead:
    Example legacy function:
    setTag(testTag, newValue)
    After conversion to ECMAScript:
    testTag = "newValue"
    or
    tags["testTag"] = "newValue"
  • Similarly, you can replace the legacy add() function with an operator:
    Example legacy function:
    add(%%testTag%%, 1)
    After conversion to ECMAScript:
    testTag + 1
  • ECMAScript functions do not recognize double percent signs (%%), so when you write a function, do not enclose the tags in double percent signs as you would in a legacy function. Rational Integration Tester tags are automatically exposed as ECMAScript local variables.
    • In most cases, you can treat the tag name as a local variable:
      Example legacy function:
      xpath(%%xml%%, %%xpathString%%)
      After conversion to ECMAScript:
      xpath(xml, xpathString)
    • Tag names that include symbols or reserved words can cause problems; in those cases use the tags["tagname"] style of notation.
      Same example, after conversion to ECMAScript:
      xpath(tags["xml"], tags["xpathString"])

For more information, see this technote about using tags with ECMAScript.


Feedback