MicroTAPAS
Class ScriptHandler

java.lang.Object
  |
  +--MicroTAPAS.ScriptHandler
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable

public class ScriptHandler
extends java.lang.Object
implements java.io.Serializable, java.lang.Runnable

Handles the execution of a script and logs the result for each executed command.

See Also:
Serialized Form

Field Summary
private  java.lang.String LF
           
 java.util.Vector log
          The log that contains all the results from executed commands.
private  ControlInterface parent
           
private  java.lang.String[] script
           
private  java.lang.String scriptFile
           
private  boolean stopOnError
           
private  java.lang.Thread thread
           
 
Constructor Summary
ScriptHandler(ControlInterface pParent, java.lang.String pScriptFile, boolean pStopOnError)
          Constructor
 
Method Summary
 void clearLog()
          Clears all test results from the action log.
private  void controlEcho(java.lang.String msg)
          Method to print a message in parent baseFrame window-
 TestResult executeCommand(java.lang.String cmd, java.lang.String[] args, boolean expectSuccess, long delay)
          Executes one single command after a delay of 'delay' milliseconds.
private  Item listResult()
           
 java.lang.String log2StringLong()
          Converts the stored test results to a string.
 java.lang.String log2StringShort()
          Converts the stored test results to a string, short format (one liners).
 TestResult logAction(java.lang.String cmd, java.lang.String[] args, boolean expectSuccess, RequestResult rr, long timeUsed)
          Adds a TestResult to the action log
private  java.util.Vector parseLine(java.lang.String script)
          Command to parse one script line into a vector of arguments used for execution.
 void run()
          Starts the thread that executes a script
private  void runScript()
          Runs a script located locally on the terminal.
 void startScript()
          Starts the execution of the script.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LF

private final java.lang.String LF
See Also:
Constant Field Values

parent

private ControlInterface parent

stopOnError

private boolean stopOnError

script

private java.lang.String[] script

thread

private java.lang.Thread thread

scriptFile

private java.lang.String scriptFile

log

public java.util.Vector log
The log that contains all the results from executed commands.

Constructor Detail

ScriptHandler

public ScriptHandler(ControlInterface pParent,
                     java.lang.String pScriptFile,
                     boolean pStopOnError)
Constructor

Method Detail

startScript

public void startScript()
Starts the execution of the script.


executeCommand

public TestResult executeCommand(java.lang.String cmd,
                                 java.lang.String[] args,
                                 boolean expectSuccess,
                                 long delay)
Executes one single command after a delay of 'delay' milliseconds.

Parameters:
cmd - The TAPAS command to be executed.
args - Any arguments to the command.
expectSuccess - True if one expect the command to be executed successfully.
delay - Delays the execution of the command by 'delay' milliseconds.
Returns:
A TestResult object containing the result of the executed command.

run

public void run()
Starts the thread that executes a script

Specified by:
run in interface java.lang.Runnable

runScript

private void runScript()
Runs a script located locally on the terminal.


controlEcho

private void controlEcho(java.lang.String msg)
Method to print a message in parent baseFrame window-

Parameters:
msg - The message to be printed.

parseLine

private java.util.Vector parseLine(java.lang.String script)
Command to parse one script line into a vector of arguments used for execution. The line must be on the form: ¤ [ ] ¤ ¤

Parameters:
script - One line of arguments
Returns:
A vector containing the arguments, vector(0) contains first and so on

listResult

private Item listResult()

logAction

public TestResult logAction(java.lang.String cmd,
                            java.lang.String[] args,
                            boolean expectSuccess,
                            RequestResult rr,
                            long timeUsed)
Adds a TestResult to the action log

Parameters:
cmd - The command that was executed
args - The command arguments
expectSuccess - Indicates if the command was expected to be successful
rr - The RequestResult of the executed command
timeUsed - The time used to executed the command (in milliseconds)

clearLog

public void clearLog()
Clears all test results from the action log.


log2StringLong

public java.lang.String log2StringLong()
Converts the stored test results to a string.

Returns:
A string representation of all stored test results.

log2StringShort

public java.lang.String log2StringShort()
Converts the stored test results to a string, short format (one liners).

Returns:
A string representation of all stored test results.


The Telematics Architecture for Plug-and-Play Systems (TAPAS) is a research project undertaken by the Norwegian University of Science and Technology's Telematics department which aims at developing an architecture for network-based service systems with a) flexibility and adaptability, b) robustness and survivability, and c) QoS awareness and resource control.

More information can be found at the project's homepage at http://tapas.item.ntnu.no and the project manager, Professor Finn Arve Aagesen, can be reached at finn.arve.aagesen@item.ntnu.no.