org.safs.rational
Class Script

java.lang.Object
  extended by RationalTestScript
      extended by org.safs.rational.Script

public abstract class Script
extends RationalTestScript

Extends RationalTestScript, and primarily makes many of its protected methods public so that we can use them.

Custom scripts invoked via the CallScript Driver Command should get a reference to the topmost executing script which will be a subclass of this org.safs.rational.Script class.

Below is the sample code for such a custom script:

 (existing imports)
 import org.safs.*;
 import org.safs.rational.*;
 import org.safs.rational.logging.RLogUtilities;
 ...
 public void testMain(Object[] args) 
 {
           Log.info("Custom Script beginning execution...");
           try{
                        // get reference to SAFS\RFT Hook
                        Script safs = (Script) getScriptCaller(); 
                        RLogUtilities safslog = safs.getLogUtilities();
                        RRobotJHook hook = safs.getRobotJHook();
                        RTestRecordData testdata = hook.getRTestRecordData();
                        STAFHelper staf = hook.getHelper();
                        
                        // do real stuff like getting values from SAFSVARS                      
                        String value = staf.getVariable("varname");

                        // sample of writing to the running test log 
                        String logname = testdata.getFac();
                        safslog.logMessage(logname, "CustomScript received varname value:"+ value);
                        safslog.logMessage(logname, "CustomScript changing the varname value to: somevalue");
 
                        // do real stuff like setting values in SAFSVARS                        
                    staf.setVariable("varname", "somevalue");
                }catch(Exception x){
                    Log.error("An error occurred in my custom script:"+ x.getMessage(),x);      
                }       
 }
...
 Then play with SAFS stuff as much as necessary.
 

Since:
JUN 24, 2003
JUN 24, 2003 (DBauman) Original Release
FEB 11, 2008 (CANAGL) Updated for CallScript usage.
JUN 24, 2009 (CANAGL) Updated doc for custom script usage

Field Summary
protected  RRobotJHook _hook
           
protected  RLogUtilities _logUtils
           
static int count
           
static int info
           
 
Constructor Summary
Script()
           
 
Method Summary
protected  IFtVerificationPoint Dummy_contentsVP()
          Locate and return the verification point Dummy_contents object in the SUT.
protected  IFtVerificationPoint Dummy_contentsVP(TestObject anchor)
           
 RDDGUIUtilities getGuiUtilities()
          Used internally and made available to scripts invoked by the CallScript Driver Commands.
 RLogUtilities getLogUtilities()
          Used internally and made available to scripts invoked by the CallScript Driver Commands.
 RRobotJHook getRobotJHook()
          Used internally and made available to scripts invoked by the CallScript Driver Commands.
 STAFHelper getSTAFHelper()
          Used internally and made available to scripts invoked by the CallScript Driver Commands
 RTestRecordData getTestRecordData()
          Used internally and made available to scripts invoked by the CallScript Driver Commands.
static Cell localAtCell(Column c, Row r)
           
static Column localAtColumn(int i)
           
static Column localAtColumn(java.lang.String key)
           
static Column localAtColumn(java.lang.String key, java.lang.Object val)
           
static Column localAtColumn(java.lang.String key1, java.lang.Object val1, java.lang.String key2, java.lang.Object val2)
           
static Column localAtColumn(java.lang.String key1, java.lang.Object val1, java.lang.String key2, java.lang.Object val2, java.lang.String key3, java.lang.Object val3)
           
static Index localAtIndex(int index)
           
static List localAtPath(java.lang.String path)
           
static java.awt.Point localAtPoint(int row, int col)
           
static Row localAtRow(int i)
           
static Row localAtRow(java.lang.String key, java.lang.Object val)
           
static Row localAtRow(java.lang.String key1, java.lang.Object val1, java.lang.String key2, java.lang.Object val2)
           
static Row localAtRow(java.lang.String key1, java.lang.Object val1, java.lang.String key2, java.lang.Object val2, java.lang.String key3, java.lang.Object val3)
           
static Text localAtText(java.lang.String name)
           
 void localCallScript(java.lang.String script)
           
 java.lang.String localGetenv(java.lang.String name)
          
Purpose: Gets the value of an environment variable.
 void localLogError(java.lang.String error)
           
 void localLogInfo(java.lang.String info)
           
 void localLogTestResult(java.lang.String message, boolean passed)
           
 void localLogTestResult(java.lang.String message, boolean passed, java.lang.String description)
           
 void localLogWarning(java.lang.String warning)
           
 ProcessTestObject localRun(java.lang.String command, java.lang.String workingDirectory)
          
Purpose: Provides the basic command-line execution functionality.
 ProcessTestObject localRunJava(java.lang.String main, java.lang.String classpath, java.lang.String workingDirectory, java.lang.String jvm, java.lang.String jvmOptions)
          Starts a Java application with the specified options.
 void localUnregister(java.lang.Object[] testobjects)
           
 void localUnregisterAll()
           
 IFtVerificationPoint localVp(java.lang.String name)
           
protected  void processArgs(java.lang.Object[] args)
          Process any -args passed into subclasses storing each as a System.property.
 void testMain(java.lang.Object[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

public static int count

info

public static int info

_hook

protected RRobotJHook _hook

_logUtils

protected RLogUtilities _logUtils
Constructor Detail

Script

public Script()
Method Detail

localAtPath

public static List localAtPath(java.lang.String path)

localAtText

public static Text localAtText(java.lang.String name)

localAtPoint

public static java.awt.Point localAtPoint(int row,
                                          int col)

localAtCell

public static Cell localAtCell(Column c,
                               Row r)

localAtRow

public static Row localAtRow(int i)

localAtColumn

public static Column localAtColumn(int i)

localAtRow

public static Row localAtRow(java.lang.String key,
                             java.lang.Object val)

localAtRow

public static Row localAtRow(java.lang.String key1,
                             java.lang.Object val1,
                             java.lang.String key2,
                             java.lang.Object val2)

localAtRow

public static Row localAtRow(java.lang.String key1,
                             java.lang.Object val1,
                             java.lang.String key2,
                             java.lang.Object val2,
                             java.lang.String key3,
                             java.lang.Object val3)

localAtColumn

public static Column localAtColumn(java.lang.String key)

localAtColumn

public static Column localAtColumn(java.lang.String key,
                                   java.lang.Object val)

localAtColumn

public static Column localAtColumn(java.lang.String key1,
                                   java.lang.Object val1,
                                   java.lang.String key2,
                                   java.lang.Object val2)

localAtColumn

public static Column localAtColumn(java.lang.String key1,
                                   java.lang.Object val1,
                                   java.lang.String key2,
                                   java.lang.Object val2,
                                   java.lang.String key3,
                                   java.lang.Object val3)

localAtIndex

public static Index localAtIndex(int index)

localVp

public IFtVerificationPoint localVp(java.lang.String name)

localCallScript

public void localCallScript(java.lang.String script)

localUnregister

public void localUnregister(java.lang.Object[] testobjects)

localUnregisterAll

public void localUnregisterAll()

localGetenv

public java.lang.String localGetenv(java.lang.String name)

Purpose: Gets the value of an environment variable.

Parameters:
name, - String
Returns:
String

localLogInfo

public void localLogInfo(java.lang.String info)

localLogWarning

public void localLogWarning(java.lang.String warning)

localLogError

public void localLogError(java.lang.String error)

localLogTestResult

public void localLogTestResult(java.lang.String message,
                               boolean passed,
                               java.lang.String description)

localLogTestResult

public void localLogTestResult(java.lang.String message,
                               boolean passed)

localRun

public ProcessTestObject localRun(java.lang.String command,
                                  java.lang.String workingDirectory)

Purpose: Provides the basic command-line execution functionality. The supplied command line is executed in host-specific fashion with the working directory set to the specified location. If the working directory is null, the script's working directory is used

Parameters:
command, - String, the command line to execute
workingDirectory, - String, The directory that the command should use as its execution context
Returns:
ProcessTestObject

localRunJava

public ProcessTestObject localRunJava(java.lang.String main,
                                      java.lang.String classpath,
                                      java.lang.String workingDirectory,
                                      java.lang.String jvm,
                                      java.lang.String jvmOptions)
Starts a Java application with the specified options. The JVM and classpath are split out because they tend to be host specific.

Parameters:
main - - The full Java class name of the class to be run. Package and class names must be included.
classpath - - Specifies the classpath that is used to run the main class. If this argument is null, the system classpath environment variable is used.
workingDirectory - - The directory that the command uses as its execution context
jvm - - The JVM that is used to execute the main class
jvmOptions - - JVM-specific options

getRobotJHook

public RRobotJHook getRobotJHook()
Used internally and made available to scripts invoked by the CallScript Driver Commands.

Scripts should get a reference to the topmost executing script which should be a subclass of this org.safs.rational.Script class.

Returns:
org.safs.rational.RRobotJHook

getSTAFHelper

public STAFHelper getSTAFHelper()
Used internally and made available to scripts invoked by the CallScript Driver Commands

Scripts should get a reference to the topmost executing script which should be a subclass of this org.safs.rational.Script class.

Returns:
org.safs.STAFHelper

getLogUtilities

public RLogUtilities getLogUtilities()
Used internally and made available to scripts invoked by the CallScript Driver Commands.

Scripts should get a reference to the topmost executing script which should be a subclass of this org.safs.rational.Script class.

Returns:
org.safs.rational.RLogUtilities

getGuiUtilities

public RDDGUIUtilities getGuiUtilities()
Used internally and made available to scripts invoked by the CallScript Driver Commands.

Scripts should get a reference to the topmost executing script which should be a subclass of this org.safs.rational.Script class.

Returns:
org.safs.rational.RDDGUIUtilities

getTestRecordData

public RTestRecordData getTestRecordData()
Used internally and made available to scripts invoked by the CallScript Driver Commands.

Scripts should get a reference to the topmost executing script which should be a subclass of this org.safs.rational.Script class.

Returns:
new (empty) org.safs.rational.RTestRecordData

testMain

public void testMain(java.lang.Object[] args)

processArgs

protected void processArgs(java.lang.Object[] args)
Process any -args passed into subclasses storing each as a System.property.

Parameters:
args - -- array of Strings formatted as name=value pairs. If an arg does not contain "=" then it will be stored as a name=name System.property.

Dummy_contentsVP

protected IFtVerificationPoint Dummy_contentsVP()
Locate and return the verification point Dummy_contents object in the SUT.


Dummy_contentsVP

protected IFtVerificationPoint Dummy_contentsVP(TestObject anchor)