com.funambol.client.test
Class BasicScriptRunner

java.lang.Object
  extended by com.funambol.client.test.CommandRunner
      extended by com.funambol.client.test.BasicScriptRunner

public class BasicScriptRunner
extends CommandRunner

The CommandRunner container implementation to run commands that are common to all the clients. This is not only a CommandRunner object itself, but also a container for any other command runner used by the given client test suite. refer to this class using the basic contructor, but remember to add explicitly implemented command runners in order to extend the command pool available to the tester. Use addcommandRunner(CommandRunner) method to achieve this goal. If no commad runner are added, no command will be effective and the run of the test suite will be unuseful. This class uses a CheckSyncClient object, a SyncMonitor and an AuthSyncMonitor to check that the requested sync operations went fine both on the client and the server side.


Field Summary
protected  int errorCode
           
 
Fields inherited from class com.funambol.client.test.CommandRunner
authSyncMonitor, checkSyncClient, robot, syncMonitor
 
Constructor Summary
BasicScriptRunner()
          Default constructor
 
Method Summary
 void addCommandRunner(CommandRunner runner)
          Add a specific CommandRunner implementation to the current BasicScriptRunner instance
protected  boolean checkCandidateStatement(java.lang.String command, boolean onExecuted)
          Check the candidate statement to be executed given a conditional command
static HttpTransportAgent createTestTransportAgent(SyncConfig config)
           
static java.lang.String getBaseUrl()
           
protected  java.lang.String getBaseUrl(java.lang.String scriptUrl)
          Get the script related base url
 int getErrorCode()
          Accessor method to retrieve the global status of the entire test suite.
protected  java.lang.String getOsVersion()
          Accessor method to retrieve the OS version
 java.lang.String getResults()
          Accessor method to retrieve the details of the failed tests
 boolean runCommand(java.lang.String command, java.lang.String pars)
          Checks the given command runner in order to execute the given command with the given arguments.
 void runScript(java.lang.String script, java.lang.String scriptUrl)
          Execute the given script by interpreting it
 void runScriptFile(java.lang.String scriptUrl, boolean mainScript)
          This method is responsible to interprete the file (being it on the device storage or taken via http), interpreting and running the commands defined by the tester.
 void setAuthSyncMonitor(SyncMonitor monitor)
          Set the AuthSyncMonitor object for this CommandRunner container
 void setCheckSyncClient(CheckSyncClient client)
          Set the CheckSyncClient object for this CommandRunner container
 void setErrorCode(int errorCode)
          Accessor method to set the global suite error code from outside (external syntax error)
 void setStopOnFailure(boolean stop)
          Tells if the script runner shall be interrupted at the first failure
 void setSyncMonitor(SyncMonitor monitor)
          Set the SyncMonitor object for this CommandRunner container
 
Methods inherited from class com.funambol.client.test.CommandRunner
checkArgument, checkObject, getParameter, getParametersCount, parseBoolean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorCode

protected int errorCode
Constructor Detail

BasicScriptRunner

public BasicScriptRunner()
Default constructor

Method Detail

addCommandRunner

public void addCommandRunner(CommandRunner runner)
Add a specific CommandRunner implementation to the current BasicScriptRunner instance

Parameters:
runner - th CommandRunner object to be added.

getBaseUrl

public static java.lang.String getBaseUrl()

runScriptFile

public void runScriptFile(java.lang.String scriptUrl,
                          boolean mainScript)
                   throws java.lang.Throwable
This method is responsible to interprete the file (being it on the device storage or taken via http), interpreting and running the commands defined by the tester. First of all the it loads the script given the remote or local url. Once the script is loaded it is parsed and the commands given to the CommandRunner array that tries to manage them using the previously added Command runners objects. The actual implementation avoid to stop whenever an error or an exception occurs. In particular: if an exception occurs it can be due to syntax errors contained into the tester script or a client test error. In both cases if the error is detected the script is entirely aborted starting from the line where the error was found. The implementation also supports inner scripts to be invoked: this means that if the error is located into an inner script the system will ignore all of the calling scripts until level 0 is reached. For example if script1 needs to include script2 that again needs script3 (chained execution) for its correct execution and an error is detected on script3: script3 and script 2 will be aborted (adding this info to the report object) and the tester will see that test case wirtten in script1 failed. This apply for all inner level script in which an error is detected. The first level script is ignored until the latest EndtTest command is found and then when the next BeginTest command is detected the test suite execution restart normally form the next text on. When such those failures occur the global report content is updated and the general error code is set to error.

Parameters:
scriptUrl - the script url String formatted
mainScript - boolean to declare that this is a main test script (not yet in use)
Throws:
java.lang.Throwable - if an error occurred while retrieving a script content. This is the only case in which the test suite is entirely aborted.

runScript

public void runScript(java.lang.String script,
                      java.lang.String scriptUrl)
               throws java.lang.Throwable
Execute the given script by interpreting it

Throws:
java.lang.Throwable

setStopOnFailure

public void setStopOnFailure(boolean stop)
Tells if the script runner shall be interrupted at the first failure

Parameters:
stop -

runCommand

public boolean runCommand(java.lang.String command,
                          java.lang.String pars)
                   throws java.lang.Throwable
Checks the given command runner in order to execute the given command with the given arguments. If no runner is defined for a given command the error is detected returning false.

Specified by:
runCommand in class CommandRunner
Parameters:
command - the String formatted command to be passed to the runners array
pars - the command's parameter.
Returns:
true if a CommandRunner defined for this object can manage the given command with the given parameters, false otherwise.
Throws:
java.lang.Throwable - if an error occurred executing the command.

getErrorCode

public int getErrorCode()
Accessor method to retrieve the global status of the entire test suite.

Returns:
int the value related to this test failure or success.

setErrorCode

public void setErrorCode(int errorCode)
Accessor method to set the global suite error code from outside (external syntax error)

Parameters:
errorCode - the int representation of the error code

getResults

public java.lang.String getResults()
Accessor method to retrieve the details of the failed tests

Returns:
String the String formatted failed test report content.

getOsVersion

protected java.lang.String getOsVersion()
Accessor method to retrieve the OS version

Returns:
the empty String. Other values are implementation specific.

checkCandidateStatement

protected boolean checkCandidateStatement(java.lang.String command,
                                          boolean onExecuted)
                                   throws java.lang.Throwable
Check the candidate statement to be executed given a conditional command

Parameters:
command - the conditional statement command
onExecuted - tries to predict the condition set in the command
Returns:
true if the command is validand must be executed, false otherwise
Throws:
java.lang.Throwable - if an error occurs.

getBaseUrl

protected java.lang.String getBaseUrl(java.lang.String scriptUrl)
Get the script related base url

Parameters:
scriptUrl - the String formatted script url
Returns:
String the base of the given url

setSyncMonitor

public void setSyncMonitor(SyncMonitor monitor)
Set the SyncMonitor object for this CommandRunner container

Overrides:
setSyncMonitor in class CommandRunner
Parameters:
monitor - the SyncMonitor to be set

setAuthSyncMonitor

public void setAuthSyncMonitor(SyncMonitor monitor)
Set the AuthSyncMonitor object for this CommandRunner container

Overrides:
setAuthSyncMonitor in class CommandRunner
Parameters:
monitor - the AuthSyncMonitor to be set

setCheckSyncClient

public void setCheckSyncClient(CheckSyncClient client)
Set the CheckSyncClient object for this CommandRunner container

Overrides:
setCheckSyncClient in class CommandRunner
Parameters:
client - the CheckSyncClient to be set

createTestTransportAgent

public static HttpTransportAgent createTestTransportAgent(SyncConfig config)


Copyright © 2001-2009 Funambol.