|Lesson #8: Using an automation harness / Working with the Java harness|
To created a scripted Java action, you must define the action, and modify the existing harness files to implement it.
This figure only describes the most important files and directories required to develop Java harness programs.
The tree resides under TA_INSTALL_DIR/harness samples/ (Windows), or /usr/local/testarchitect/harness_samples (Linux).
|java||directory||Root directory of the sample Java harness.|
|java/executables||directory||Executable files of Java harness programs.|
|java/executables/java_harnress.bat||file||A simple startup script. Its objective is to run the executable Java program file, java_harness.jar.|
|java/executables/java_harness.jar||file||An executable Java file invoked by the java_harness.bat file.|
|java/source||directory||Contains all necessary files used to implement Java harness code.|
|java/source/lib||directory||Libraries used to tell the harness code where to find the Java implementation of the automation library.|
|java/source/src||directory||Contains source code that shows how to program for the Java harness.|
|java/source/build.xml||file||An XML file that is used by Another Neat Tool (ANT) technology to build an excutable JAR file, which is java_harness.jar.|
The folder java/source/src/com/testarchitect/java/user, contains the following three files:
TAMain.java is the startup Java script. Running this file executes the main() function, which sets the actions and starts the TestArchitect interpreter.
Lib_Interpret.java contains all the necessary functions for TestArchitect interpreter.
Your action definitions in Java may be grouped into separate Java classes, each of which is a .java file; it is in TAMain.java that the appropriate class for a given action is invoked. When a given action definition is requested by the interpreter, TAMain’s divert() function passes execution to the module in which that definition exists.
Only a single class, Mod_Example.java, exists in your harness samples/java/source/src/com/testarchitect/java/user directory (assuming you have a fresh installation of TestArchitect). In its unmodified form, it contains the Java code to define a single action, hello world, which writes the text string hello world to the results.
The convention is to organize user-scripted functions into multiple script class files, with the name of each such file prefixed with the string "Mod_" . If you add new actions, you may want to do so in new script files, depending on whether or not the actions logically fit within an existing module.
In this lesson you will write an action and add it to class Mod_Example.java . In the subsequent lesson, you will write another action, but will create an entirely new script module to hold it.