com.webmbt.plugin
Class MbtScriptExecutor

java.lang.Object
  extended by com.webmbt.plugin.MbtScriptExecutor

public class MbtScriptExecutor
extends java.lang.Object

Executes the mScript.

Author:
yxl01

Nested Class Summary
static interface MbtScriptExecutor.MSCRIPT_METHOD
          Indicates that the annotated method is a test method.
 
Field Summary
 java.lang.String seqOutPrefix
          to be added to the beginning of every seqout message call.
 
Constructor Summary
MbtScriptExecutor(com.webmbt.ExecutionDirector execDirector_p, com.webmbt.FSM.MbtExecWorker execWorker_p)
          INTERNAL USE ONLY.
 
Method Summary
 void abort(java.lang.String msg_p)
          raises Exception to cause the MBT execution to abort.
 void actionDelay(com.webmbt.scxml.TransitionNode transNode_p)
          INTERNAL USE ONLY.
 java.lang.String add(java.lang.String expr1, java.lang.String expr2)
          add two exprs.
 void addTagCheck(java.lang.String tag_p, java.lang.String passed_p, java.lang.String msg_p)
          adds a tag check/validation message to the tag stat.
 boolean and(java.lang.String expr1_p, java.lang.String expr2_p)
          performs AND operation on the two mScript expressions passed in and returns a true if both expressions evaluate to true, else return false.
 boolean and(java.lang.String expr1_p, java.lang.String expr2_p, java.lang.String expr3_p)
          performs AND operation on the three mScript expressions passed in and returns a true if all expressions evaluate to true, else return false.
 java.lang.String callFunc(java.lang.String funcName_p)
          calls a user function without parameters.
 java.lang.String callFunc(java.lang.String funcName_p, java.lang.String params_p)
          calls a user function with parameters.
 java.lang.String callURL(java.lang.String urlString_p)
          calls the url passed in and returns the content returned from the url.
 java.lang.String checkSeqNum()
          returns the current seqNum without incrementing it.
 java.lang.String chooseMsg(java.lang.String expr_p, java.lang.String trueMsg_p, java.lang.String falseMsg_p)
          evaluates the expression passed in, if the expression evaluates to true, it returns the value from the trueMsg_p expression (may contain other mScript function calls).
 void clearAllPathVars()
          clears all variables on the current traversal path.
 void close()
          perform the cleanup including causing all plugins to be closed/destroyed.
 boolean compare(java.lang.String expr1_p, java.lang.String op_p, java.lang.String expr2_p)
          performs comparison between two expressions passed in using the operator specified.
 java.lang.String dataSetInfo(java.lang.String dataSetID_p)
          returns the data set info in a string.
 java.lang.String date()
          returns todays date string in standard format: MM/dd/yyyy.
 java.lang.String date(java.lang.String dateExpr_p)
          returns a date string in standard format MM/dd/yyyy.
 java.lang.String date(java.lang.String dateExpr_p, java.lang.String dateFmr_p)
          returns a date string in java date format specified.
 void debug(java.lang.String msg_p)
          INTERNAL USE ONLY.
 java.lang.String decrement(java.lang.String varName_p)
          decrement the variable by 1.
 void entryDelay(com.webmbt.scxml.StateNode state_p)
          INTERNAL USE ONLY.
 void error(java.lang.Exception e)
          INTERNAL USE ONLY.
 void error(java.lang.String msg_p)
          INTERNAL USE ONLY.
 void error(java.lang.String msg_p, java.lang.Throwable e_p)
          INTERNAL USE ONLY.
 java.lang.String evalExpr(java.lang.String expr_p)
          performs mScript expression evaluation.
 int evalExprToInt(java.lang.String expr_p)
          performs mScript expression evaluation to an integer.
 boolean evalGuard(com.webmbt.scxml.TransitionNode transObj_p)
          INTERNAL USE ONLY evaluates the guard condition of the transition passed in.
 java.lang.String execMScriptMethod(java.lang.String methodScript_p)
          INTERNAL USE ONLY.
 java.lang.String execSQL(java.lang.String dbID_p, java.lang.String sqlStmt_p, java.lang.String colName_p, java.lang.String delimeter_p)
          executes an SQL statement and return the result from the specified column name with rows separated by the delimited specified
 com.webmbt.mscript.UserFuncScriptCall executeFunc(java.lang.String funcName_p, java.util.HashMap<java.lang.String,java.lang.String> params_p)
          calls a user function.
 boolean executeScript(com.webmbt.ScriptDesc script_p)
          INTERNAL USE ONLY.
 java.lang.Integer findData(java.lang.String dataSetID_p, java.lang.String fieldNames_p, java.lang.String compValues_p)
          Returns the number of data rows found to match the compValues_p.
 java.lang.Integer findDataRowIndex(java.lang.String dataSetID_p, java.lang.String fieldNames_p, java.lang.String compValues_p)
          Returns the row index of the first data row found that matches the compValues_p.
 java.lang.String getBrowser()
          returns browser set for the model.
 java.lang.String getBrowserVersion()
          returns version number of the brower set for the model, for example IE 7 it will return "7".
 java.lang.String getData(java.lang.String dataSetIDFieldName_p)
          returns the field in the data set at the current row.
 java.lang.String getData(java.lang.String dataSetID_p, java.lang.String fieldName_p)
          return the field in the data set at the current row.
 java.lang.String getData(java.lang.String dataSetID_p, java.lang.String rowIdx_p, java.lang.String fieldName_p)
          return the field in the data set at the row specified in the rowIdx_p.
 java.lang.String[] getDataAllRows(java.lang.String dataSetID_p, java.lang.String fieldName_p)
          returns column fieldName_p for all rows in the data set in a string separated by semi-colon ";".
 com.webmbt.mscript.DataManager getDataMgr()
          INTERNAL USE ONLY
 java.lang.String getDataSetRow(java.lang.String dataSetID_p)
          returns the current row in a string with key=value,key=value
 int getDataSetRowNum(java.lang.String dataSetID_p)
          returns the current row index
static java.lang.String getDefaultMbtScriptName(com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
          INTERNAL USE ONLY.
static java.lang.String getDefaultScriptName(com.webmbt.scxml.StateNode stateNode_p, com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
          INTERNAL USE ONLY.
static java.lang.String getDefaultScriptName(com.webmbt.scxml.TransitionNode transNode_p, com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
          INTERNAL USE ONLY.
static java.lang.String getDefaultScriptName(com.webmbt.scxml.UseCaseNode useCaseNode_p, com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
          INTERNAL USE ONLY.
static java.lang.String getDefaultScriptName(com.webmbt.scxml.UseCaseStepNode stepNode_p, com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
          INTERNAL USE ONLY.
static java.util.ArrayList<com.webmbt.MBTException> getExceptionList()
          INTERNAL USE ONLY.
 com.webmbt.ExecutionDirector getExecDirector()
          INTERNAL USE ONLY.
 com.webmbt.FSM.MbtExecWorker getExecWorker()
          INTERNAL USE ONLY.
 java.lang.String getFuncParam(java.lang.String paramName_p)
          returns the param value for the user function in current scope.
 org.apache.log4j.Logger getLogObj()
          INTERNAL USE ONLY.
 com.webmbt.scxml.MbtNode getMbtNode()
          INTERNAL USE ONLY.
static java.lang.String[] getMbtScriptMethodList()
          INTERNAL USE ONLY.
 com.webmbt.ModelMgr getModelMgr()
           
static java.util.List<java.lang.reflect.Method> getMScriptMethodDeclareList(java.lang.Class class_p, java.lang.Class filterClass_p)
           
 java.lang.Object getPathVar(java.lang.String varName_p)
          retrieve a variable from the current traversal path.
 java.lang.String getPluginID()
          returns ID of the plugin currently selected for the model.
 java.util.List<PluginAncestor> getPluginList()
          INTERNAL USE ONLY.
 PluginMgr getPluginMgr()
           
 com.webmbt.scxml.ScxmlNode getScxmlNode()
          INTERNAL USE ONLY.
 SeqOutPlugin getSeqOutPlugin()
          INTERNAL USE ONLY
 java.lang.String getSysConfig(java.lang.String propertyName_p)
          returns the property value from the system config.
 java.lang.String getSysConfig(java.lang.String propertyName_p, java.lang.String defaultValue_p)
          returns the property value from the system config.
 java.lang.String getSysVar(java.lang.String varName_p)
          Returns value for the system variable.
 java.lang.String getSysVar(java.lang.String varName_p, java.lang.String param_p)
          returns system variable that requires a parameter.
 java.lang.String getTransData(java.lang.String fieldName_p)
          retrieves the DDT field value defined for the current transition.
 java.lang.Object getVar(java.lang.String varName_p)
          Returns the value for the varName_p passed in.
 java.lang.String getVar(java.lang.String varName_p, java.lang.String index_p)
          Returns the value for the variable at the index passed in.
 java.lang.String[] getVarAllRows(java.lang.String varName_p)
          returns a field on all rows in the data set, that is, returns a column in the data set.
 java.util.HashMap<java.lang.String,java.lang.Object> getVarList()
           
 int getVarRowNum(java.lang.String varName_p)
          Returns the current row number (subscript) of the variable name passed in.
 void gotoState(java.lang.String gotoStateID_p)
          requests next state be set to the state id specified.
 void gotoTrans(java.lang.String gotoTransStateID_p, java.lang.String gotoTransID_p)
          requests the transition passed in be performed next.
 void gotoURL(java.lang.String url_p)
          Set current web page to the url passed in.
 java.lang.String ifFalseMsg(java.lang.String expr_p, java.lang.String msg_p)
          evaluates the expression passed in, if the expression evaluates to false, it returns the message expression (may contain other mScript function calls).
 java.lang.String ifTrueMsg(java.lang.String expr_p, java.lang.String msg_p)
          evaluates the expression passed in, if the expression evaluates to true, it returns the message expression (may contain other mScript function calls).
 java.lang.String increment(java.lang.String varName_p)
          increments the variable by 1.
 java.lang.String increment(java.lang.String varName_p, java.lang.String delta_p)
          increment the variable by the delta passed in.
 void info(java.lang.String msg_p)
          INTERNAL USE ONLY.
 void init()
          INTERNAL USE ONLY.
 void internalLoadDataSet(java.lang.String dataSetID_p, java.lang.String... paramList_p)
          INTERNAL USE ONLY.
 boolean isFalse(java.lang.String expr_p)
          evaluates the mScript expression and return the negation of the boolean result from the expression.
 boolean isModelRunning(java.lang.String modelName_p)
          returns true if the model specified is also running in the same TestOptimal server.
 boolean isTrue(java.lang.String expr_p)
          evaluates the mScript expression and return true if the result is one of the representation of Boolean true: true, T, 1, yes, Y, etc.
 java.lang.String listFuncParams()
          returns a string that represent parameters.
 void loadFromDataSource(java.lang.String dataSetID_p)
          loads the data set from the data source defined without parameters.
 void loadFromDataSource(java.lang.String dataSetID_p, java.lang.String param1_p)
          loads the data set from the data source defined with one parameter.
 void loadFromDataSource(java.lang.String dataSetID_p, java.lang.String param1_p, java.lang.String param2_p)
          loads the data set from the data source defined with two parameters.
 void loadFromDataSource(java.lang.String dataSetID_p, java.lang.String param1_p, java.lang.String param2_p, java.lang.String param3_p)
          loads the data set from the data source defined with three parameters.
 void loadFromDataSource(java.lang.String dataSetID_p, java.lang.String param1_p, java.lang.String param2_p, java.lang.String param3_p, java.lang.String param4_p)
          loads the data set from the data source defined with four parameters.
 void loadFromDataSource(java.lang.String dataSetID_p, java.lang.String param1_p, java.lang.String param2_p, java.lang.String param3_p, java.lang.String param4_p, java.lang.String param5_p)
          loads the data set from the data source defined with five parameters.
 void mscriptDelay()
          INTERNAL USE ONLY.
 java.lang.String multiply(java.lang.String expr1, java.lang.String expr2)
          multiply two exprs.
 boolean nand(java.lang.String expr1_p, java.lang.String expr2_p)
           
 boolean nand(java.lang.String expr1_p, java.lang.String expr2_p, java.lang.String expr3_p)
          performs NAND on the expression list passed.
 int nextDataSetRow(java.lang.String dataSetID_p)
          moves data set to next row.
 int nextDataSetRow(java.lang.String dataSetID_p, java.lang.String floatIdx_p)
          moves the data set to a row randomly selected.
 int nextVarRow(java.lang.String varName_p)
          Advances the variable current row number by 1.
 boolean nor(java.lang.String expr1_p, java.lang.String expr2_p)
           
 boolean nor(java.lang.String expr1_p, java.lang.String expr2_p, java.lang.String expr3_p)
          performs NOR on the expression list passed.
 boolean not(java.lang.String expr_p)
          evaluates the mScript expression and return the negation of the boolean result from the expression.
 boolean or(java.lang.String expr1_p, java.lang.String expr2_p)
          performs OR operation on the two mScript expressions passed in and returns a true if any of the expressions evaluates to true, else return false.
 boolean or(java.lang.String expr1_p, java.lang.String expr2_p, java.lang.String expr3_p)
          performs OR operation on the three mScript expressions passed in and returns a true if any of the expressions evaluates to true, else return false.
 void osCmd(java.lang.String cmd_p)
          osCmd: runs an os command.
 void osCmd(java.lang.String cmd_p, java.lang.String killAfterMillis_p)
          osCmd: runs an os command, waits for the specified milliseconds and stops the application.
 void osCmdAsynch(java.lang.String cmd_p)
          osCmd: runs an os command asynchronously.
 java.lang.String peek(java.lang.String varName_p)
          peeks the last value in stack without pop it.
 java.lang.String pop(java.lang.String varName_p)
          pops the last value from stack.
 void popAll(java.lang.String varName_p)
          clears the stack.
 void push(java.lang.String varName_p, java.lang.String value_p)
          push a value into a stack variable.
 float rand()
          returns a random number in float between 0 (inclusive) and 1 (exclusive).
 int rand(java.lang.String limit_p)
          returns a random integer number between 0 (inclusive) and limit_p (exclusive).
 int rand(java.lang.String startInt_p, java.lang.String endInt_p)
          returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).
 java.lang.String rand(java.lang.String startNum_p, java.lang.String endNum_p, java.lang.String precisionDigit_p)
          returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).
 boolean randBool()
          returns a randomly chosen true or false.
 void registerVarChangeListener(com.webmbt.mscript.VarChangeListener listener_p)
          INTERNAL USE ONLY
 void removeVarChangeListener(com.webmbt.mscript.VarChangeListener listener_p)
          INTERNAL USE ONLY
 void resetSeqNum()
          resets the seqNum sys var to 0.
 void rewindDataSet(java.lang.String dataSetID_p)
          reset the data set to start at the first row.
 int rewindVar(java.lang.String varName_p)
          sets the current row number for the variable to 0.
 void sendMail(java.lang.String fromAddress, java.lang.String toAddress, java.lang.String subject, java.lang.String messageText)
          send mail.
 void seqout(java.lang.String seqText_p)
          writes a message to seq.out (SeqOut) file in the model folder.
 boolean setData(java.lang.String dataSetID_p, java.lang.String fieldName_p, java.lang.String value_p)
          changes a field in the data set.
 void setDataSetRow(java.lang.String dataSetID_p, java.lang.String rowIdx_p)
          moves the data set to a row specified.
 void setFuncReturn(java.lang.String retVal_p)
          sets the return value for the current user function.
 void setPathVar(java.lang.String varName_p, java.lang.String varVal_p)
          sets a specific traversal path variable to the value passed in.
 void setPathVarObj(java.lang.String varName_p, java.lang.Object varVal_p)
           
 void setSeqNum(java.lang.String seqNum_p)
          sets sys var seqNum to the value specified.
 boolean setVar(java.lang.String varName_p, java.lang.String toValue_p)
          returns true if value has changed.
 boolean setVar(java.lang.String varName_p, java.lang.String toValue_p, java.lang.String modelName_p)
          Sets a variable on a different model execution.
 void setVarRowNum(java.lang.String varName_p, java.lang.String rowNum_p)
          Sets the current row number (subscript) for mbt variable passed in.
static void shutdown()
          INTERNAL USE ONLY.
 void sleep(java.lang.String millis_p)
          sleeps for number of milliseconds.
 java.lang.String snapScreen()
          To cause a snapshot of current screen of AUT.
 java.lang.String snapScreen(java.lang.String fileName_p)
          To cause a snapshot of current screen of AUT.
 java.lang.String time()
          returns current time in string in standard time format MM/dd/yyyy HH:mm.
 java.lang.String time(java.lang.String timeExpr_p)
          returns time in a string in standard time format MM/dd/yyyy HH:mm.
 java.lang.String time(java.lang.String timeExpr_p, java.lang.String timeFmt_p)
          returns a time string in java date/time format specified.
 java.lang.String trace(java.lang.String maxLogCount_p)
          returns the trace in a string of last maxLogCount_p traversals leading up to the current state/transition.
 boolean useSeqOutPlugin()
          INTERNAL USE ONLY
 java.lang.String waitForVarChanged(java.lang.String varName_p)
          waits until the variable specified has changed its value and return the new value.
 java.lang.String waitForVarChanged(java.lang.String varName_p, java.lang.String timeoutMillis_p)
          waits until the variable specified has changed its value and return the new value.
 java.lang.String waitForVarChanged(java.lang.String varName_p, java.lang.String timeoutMillis_p, java.lang.String newValue_p)
          waits until the variable specified has changed its value.
 boolean xor(java.lang.String expr1_p, java.lang.String expr2_p)
           
 boolean xor(java.lang.String expr1_p, java.lang.String expr2_p, java.lang.String expr3_p)
          performs XOR on the expression list passed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

seqOutPrefix

public java.lang.String seqOutPrefix
to be added to the beginning of every seqout message call. Caller should adjust this accordingly before each seqout() call.

Constructor Detail

MbtScriptExecutor

public MbtScriptExecutor(com.webmbt.ExecutionDirector execDirector_p,
                         com.webmbt.FSM.MbtExecWorker execWorker_p)
                  throws java.lang.Exception
INTERNAL USE ONLY. Constructor, inititalizes the mbtControl with the webAppMBT object and the current working directory.

Throws:
java.lang.Exception
Method Detail

getExceptionList

public static java.util.ArrayList<com.webmbt.MBTException> getExceptionList()
INTERNAL USE ONLY. returns the list of exceptions caused by current (last executed) script.

Returns:

getMbtScriptMethodList

public static java.lang.String[] getMbtScriptMethodList()
INTERNAL USE ONLY. returns a static list of standard mScript functions.

Returns:

debug

public void debug(java.lang.String msg_p)
INTERNAL USE ONLY. prints a debug log message to log file

Parameters:
msg_p -

info

public void info(java.lang.String msg_p)
INTERNAL USE ONLY. prints an info log message to log file

Parameters:
msg_p -

error

public void error(java.lang.String msg_p)
INTERNAL USE ONLY. prints an error log message to log file.

Parameters:
msg_p -

getLogObj

public org.apache.log4j.Logger getLogObj()
INTERNAL USE ONLY. returns the log4j object.

Returns:

error

public void error(java.lang.String msg_p,
                  java.lang.Throwable e_p)
INTERNAL USE ONLY. logs the exception to log file.

Parameters:
msg_p -
e_p -

error

public void error(java.lang.Exception e)
INTERNAL USE ONLY. logs the exception to log file.

Parameters:
e -

getDefaultMbtScriptName

public static java.lang.String getDefaultMbtScriptName(com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
INTERNAL USE ONLY. Returns the dynamically constructed MBT script execution method name

Parameters:
execType_p -
Returns:

getDefaultScriptName

public static java.lang.String getDefaultScriptName(com.webmbt.scxml.StateNode stateNode_p,
                                                    com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
INTERNAL USE ONLY. Returns the dynamically constructed MBT script execution method name

Parameters:
stateNode_p -
execType_p -
Returns:

getDefaultScriptName

public static java.lang.String getDefaultScriptName(com.webmbt.scxml.TransitionNode transNode_p,
                                                    com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
INTERNAL USE ONLY. Returns the dynamically constructed MBT script execution method name

Parameters:
transNode_p -
execType_p -
Returns:

getDefaultScriptName

public static java.lang.String getDefaultScriptName(com.webmbt.scxml.UseCaseStepNode stepNode_p,
                                                    com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
INTERNAL USE ONLY. Returns the dynamically constructed MBT script execution method name

Parameters:
stepNode_p -
execType_p -
Returns:

getDefaultScriptName

public static java.lang.String getDefaultScriptName(com.webmbt.scxml.UseCaseNode useCaseNode_p,
                                                    com.webmbt.mscript.tag.ScriptTag.ScriptType execType_p)
INTERNAL USE ONLY. Returns the dynamically constructed MBT script execution method name

Parameters:
useCaseNode_p -
execType_p -
Returns:

getMbtNode

public com.webmbt.scxml.MbtNode getMbtNode()
INTERNAL USE ONLY. returns the MbtNode for the current model.

Returns:

getScxmlNode

public com.webmbt.scxml.ScxmlNode getScxmlNode()
INTERNAL USE ONLY. returns the ScxmlNode for the current model.

Returns:

getModelMgr

public com.webmbt.ModelMgr getModelMgr()

getExecWorker

public com.webmbt.FSM.MbtExecWorker getExecWorker()
INTERNAL USE ONLY.

Returns:

getExecDirector

public com.webmbt.ExecutionDirector getExecDirector()
INTERNAL USE ONLY.

Returns:

executeScript

public boolean executeScript(com.webmbt.ScriptDesc script_p)
                      throws java.lang.Exception
INTERNAL USE ONLY. executes the script passed in. It returns true if the script was executed as an mScript or by any of the plugins. Otherwise it returns false. Note the same script method may be implemented by mScript as well as several plugins and they would be all executed one after the other.

Parameters:
scriptMethodName_p - method name
Returns:
true if found the method and executed, false if no default script method is found.
Throws:
java.lang.Exception

getMScriptMethodDeclareList

public static java.util.List<java.lang.reflect.Method> getMScriptMethodDeclareList(java.lang.Class class_p,
                                                                                   java.lang.Class filterClass_p)

shutdown

public static void shutdown()
INTERNAL USE ONLY.


executeFunc

public com.webmbt.mscript.UserFuncScriptCall executeFunc(java.lang.String funcName_p,
                                                         java.util.HashMap<java.lang.String,java.lang.String> params_p)
                                                  throws java.lang.Exception
calls a user function. No recursive is allowed.

Parameters:
funcName_p -
Returns:
Throws:
java.lang.Exception

actionDelay

public void actionDelay(com.webmbt.scxml.TransitionNode transNode_p)
INTERNAL USE ONLY. performs model delay as defined in model property and transition property.


mscriptDelay

public void mscriptDelay()
INTERNAL USE ONLY. performs model delay as defined in model property.


entryDelay

public void entryDelay(com.webmbt.scxml.StateNode state_p)
INTERNAL USE ONLY. performs entry delay as defined in state property.


getPluginList

public java.util.List<PluginAncestor> getPluginList()
INTERNAL USE ONLY. returns the list of plugins activated.


init

public void init()
          throws java.lang.Exception
INTERNAL USE ONLY. calls start method of each plugin.

Throws:
java.lang.Exception

internalLoadDataSet

public void internalLoadDataSet(java.lang.String dataSetID_p,
                                java.lang.String... paramList_p)
                         throws java.lang.Exception
INTERNAL USE ONLY. loads data from datasource

Throws:
java.lang.Exception

getDataMgr

public com.webmbt.mscript.DataManager getDataMgr()
INTERNAL USE ONLY

Returns:

registerVarChangeListener

public void registerVarChangeListener(com.webmbt.mscript.VarChangeListener listener_p)
INTERNAL USE ONLY

Parameters:
listener_p -

removeVarChangeListener

public void removeVarChangeListener(com.webmbt.mscript.VarChangeListener listener_p)
INTERNAL USE ONLY

Parameters:
listener_p -

execMScriptMethod

public java.lang.String execMScriptMethod(java.lang.String methodScript_p)
                                   throws java.lang.Exception
INTERNAL USE ONLY. dynamic execute mScript method.

Throws:
java.lang.Exception

loadFromDataSource

public void loadFromDataSource(java.lang.String dataSetID_p)
                        throws java.lang.Exception
loads the data set from the data source defined without parameters.

Example: <action code="$loadFromDataSource('myDS')"/>

Parameters:
dataSetID_p - data set id. data set id must be unique among all data sets.
Throws:
java.lang.Exception - on any error

loadFromDataSource

public void loadFromDataSource(java.lang.String dataSetID_p,
                               java.lang.String param1_p)
                        throws java.lang.Exception
loads the data set from the data source defined with one parameter.

Example: <action code="$loadFromDataSource('myDS', 'p1')"/>

Parameters:
dataSetID_p - data set id, data set id must be unique among all data sets.
param1_p - parameter to be used to load the data from the data source
Throws:
java.lang.Exception - on any error

loadFromDataSource

public void loadFromDataSource(java.lang.String dataSetID_p,
                               java.lang.String param1_p,
                               java.lang.String param2_p)
                        throws java.lang.Exception
loads the data set from the data source defined with two parameters.

Example: <action code="$loadFromDataSource('myDS','p1','p2')"/>

Parameters:
dataSetID_p - data set id, data set id must be unique among all data sets.
param1_p - value for the first parameter in the load query
param2_p - value for the second parameter in the load query
Throws:
java.lang.Exception - on any error

loadFromDataSource

public void loadFromDataSource(java.lang.String dataSetID_p,
                               java.lang.String param1_p,
                               java.lang.String param2_p,
                               java.lang.String param3_p)
                        throws java.lang.Exception
loads the data set from the data source defined with three parameters.

Example: <action code="$loadFromDataSource('myDS','p1','p2','p3')"/>

Parameters:
dataSetID_p - data set id, data set id must be unique among all data sets.
param1_p - value for the first parameter in the load query
param2_p - value for the second parameter in the load query
param3_p - value for the third parameter in the load query
Throws:
java.lang.Exception

loadFromDataSource

public void loadFromDataSource(java.lang.String dataSetID_p,
                               java.lang.String param1_p,
                               java.lang.String param2_p,
                               java.lang.String param3_p,
                               java.lang.String param4_p)
                        throws java.lang.Exception
loads the data set from the data source defined with four parameters.

Example: <action code="$loadFromDataSource('myDS','p1','p2','p3','p4')"/>

Parameters:
dataSetID_p - data set id, data set id must be unique among all data sets.
param1_p - value for the first parameter in the load query
param2_p - value for the second parameter in the load query
param3_p - value for the third parameter in the load query
param4_p - value for the fourth parameter in the load query
Throws:
java.lang.Exception

loadFromDataSource

public void loadFromDataSource(java.lang.String dataSetID_p,
                               java.lang.String param1_p,
                               java.lang.String param2_p,
                               java.lang.String param3_p,
                               java.lang.String param4_p,
                               java.lang.String param5_p)
                        throws java.lang.Exception
loads the data set from the data source defined with five parameters.

Example: <action code="$loadFromDataSource('myDS','p1','p2','p3','p4','p5')"/>

Parameters:
dataSetID_p - data set id, data set id must be unique among all data sets.
param1_p - value for the first parameter in the load query
param2_p - value for the second parameter in the load query
param3_p - value for the third parameter in the load query
param4_p - value for the fourth parameter in the load query
param5_p - value for the fifth parameter in the load query
Throws:
java.lang.Exception

close

public void close()
perform the cleanup including causing all plugins to be closed/destroyed.

use this method to perform any cleanup you might want to do before the execution is completed. A typical use might be to write a record to database to indicate the execution completed and time of completion.

INTERNAL USE ONLY


snapScreen

public java.lang.String snapScreen()
                            throws java.lang.Exception
To cause a snapshot of current screen of AUT. The output file type depends on the plugin being used. Selenium takes an image of the screen in jpg while HtmlUnit takes a copy of html source file.

Typical use of this method is to call it in or trigger to take a snapshot of the screen of the error.

The screen shot will be marked with the first exception (if multiple exceptions) triggered by current mScript and thus available from the exception popup.

Example: <action code="$snapScreen()"/>

Throws:
java.lang.Exception
See Also:
trace(java.lang.String)

snapScreen

public java.lang.String snapScreen(java.lang.String fileName_p)
                            throws java.lang.Exception
To cause a snapshot of current screen of AUT. The output file type depends on the plugin being used. Selenium takes an image of the screen in jpg while HtmlUnit takes a copy of html source file.

Typical use of this method is to call it in or trigger to take a snapshot of the screen of the error.

The screen shot will be marked with the first exception (if multiple exceptions) triggered by current mScript and thus available from the exception popup.

Example: <action code="$snapScreen('myFileName')"/>

Parameters:
fileName_p - name of the file, final file name will suffixed with "_timestamp".
Throws:
java.lang.Exception
See Also:
trace(java.lang.String)

gotoURL

public void gotoURL(java.lang.String url_p)
             throws java.lang.Exception
Set current web page to the url passed in.

It may be used to force current page to be at the specified url on error or failure to reset the page to the correct page for the subsequent sequence to continue.

Example: <action code="$gotoURL('http://google.com')"/>

Throws:
java.lang.Exception

osCmd

public void osCmd(java.lang.String cmd_p)
           throws java.lang.Exception
osCmd: runs an os command.

A typical use might be to call OS email utilty to send email or run a batch file or shell script to perform certain action. Note this method does not return a result.

Use this command to run an external application or scripts that will complete right away. If the application will stay up, use $osCmdAsynch() instead.

Example: <action code="$osCmd('dir c:/')"/>

Throws:
java.lang.Exception
See Also:
osCmdAsynch()

osCmdAsynch

public void osCmdAsynch(java.lang.String cmd_p)
                 throws java.lang.Exception
osCmd: runs an os command asynchronously.

A typical use might be to call OS email utilty to send email or run a batch file or shell script to perform certain action. Note this method does not return a result.

Example: <action code="$osCmdAsynch('c:/myapp.exe')"/>

Throws:
java.lang.Exception
See Also:
osCmdAsynch()

osCmd

public void osCmd(java.lang.String cmd_p,
                  java.lang.String killAfterMillis_p)
           throws java.lang.Exception
osCmd: runs an os command, waits for the specified milliseconds and stops the application.

A typical use might be to call OS perform an operation using os command or custom application (exe).

Example: <action code="$osCmd('c:/myApp.exe','5000')"/>

Throws:
java.lang.Exception

abort

public void abort(java.lang.String msg_p)
           throws java.lang.Exception
raises Exception to cause the MBT execution to abort.

Can be used anywhere in mScript. It will trigger if one is declared.

Example:

<if val1="$containsText('FATAL ERROR XYZ')" op="eq" val2="true">

 nbsp;<action code="$abort('Fatal error detected')"/>

</if>

Throws:
java.lang.Exception

nextDataSetRow

public int nextDataSetRow(java.lang.String dataSetID_p)
moves data set to next row. If data set is defined to auto rewind, it will reset to first row when it reaches end of the list. Otherwise, it will stay at the last row when it reaches the end of the list.

Example: <action code="$nextDataSetRow('myDS')"/>

Parameters:
dataSetID_p - data set id
Returns:
new row number for the data set

nextDataSetRow

public int nextDataSetRow(java.lang.String dataSetID_p,
                          java.lang.String floatIdx_p)
moves the data set to a row randomly selected.

Example, "$nextDataSetRow('ds1', '0.5')" will attempt to set to a row in the middle of the data set. On any error, it will set the data set to the next row.

Parameters:
floatIdx_p - a random float number between 0 and 1, use 0 for first row, 1.0 for last row, 0.5 for the middle row in the data set.
dataSetID_p - data set id
dataSetID_p - data set id

setDataSetRow

public void setDataSetRow(java.lang.String dataSetID_p,
                          java.lang.String rowIdx_p)
moves the data set to a row specified.

Example, "$setDataSetRow('ds1', '2')" will attempt to set to the 3rd row in the data set.

Parameters:
floatIdx_p - row number 0-based.
dataSetID_p - data set id

rewindDataSet

public void rewindDataSet(java.lang.String dataSetID_p)
reset the data set to start at the first row.

Example: <action code="$rewindDataSet('myDS')"/>

Parameters:
dataSetID_p - data set id

dataSetInfo

public java.lang.String dataSetInfo(java.lang.String dataSetID_p)
returns the data set info in a string.

Use this method for debugging to examine the status of the data set.

Example: <log msg="$dataSetInfo('ds1')"/>.

Parameters:
dataSetID_p - data set id
Returns:
a string the describes the data set.

getDataAllRows

public java.lang.String[] getDataAllRows(java.lang.String dataSetID_p,
                                         java.lang.String fieldName_p)
returns column fieldName_p for all rows in the data set in a string separated by semi-colon ";".

Example: <log msg="DataSet myDS.F1: $getDataAllRows('myDS', 'F1')"/>

Parameters:
dataSetID_p - data set id
fieldName_p - field name
Returns:
a string the represents the result. If an array was returned, the array elements will be strung with semi-colon as the delimeter.

getDataSetRow

public java.lang.String getDataSetRow(java.lang.String dataSetID_p)
returns the current row in a string with key=value,key=value

Example: <log msg="current dataset row for myDS: $getDataSetRow('myDS')"/>

Parameters:
dataSetID_p - data set id
Returns:
a string the represents the entire row of current row in the data set.

getDataSetRowNum

public int getDataSetRowNum(java.lang.String dataSetID_p)
returns the current row index

Example: <log msg="current dataset row for myDS: $getDataSetRowNum('myDS')"/>

Parameters:
dataSetID_p - data set id
Returns:
current row number (index), -1 for unknown dataset or data set not loaded, 0 for first row.
Since:
3.0.25

getData

public java.lang.String getData(java.lang.String dataSetID_p,
                                java.lang.String rowIdx_p,
                                java.lang.String fieldName_p)
                         throws com.webmbt.MBTException
return the field in the data set at the row specified in the rowIdx_p.

Example: <log msg="current row F1 on myDS: $getData('myDS','F1')"/>

Parameters:
dataSetID_p - data set id
rowIdx_p - row index
fieldName_p - field name
Returns:
string value of the field
Throws:
com.webmbt.MBTException

getData

public java.lang.String getData(java.lang.String dataSetID_p,
                                java.lang.String fieldName_p)
                         throws com.webmbt.MBTException
return the field in the data set at the current row.

Example: <log msg="current row F1 on myDS: $getData('myDS','F1')"/>

Parameters:
dataSetID_p - data set id
fieldName_p - field name
Returns:
string value of the field
Throws:
com.webmbt.MBTException

getData

public java.lang.String getData(java.lang.String dataSetIDFieldName_p)
                         throws com.webmbt.MBTException
returns the field in the data set at the current row. The data set is specified in dataSetIdFieldName_p as: dataSetID:fieldName.

Example "$getData('ds1:f1')" to return the value of field "f1" in data set "ds1" at the current row.

Parameters:
dataSetIDFieldName_p - data set id and field name combined separated by colon ":".
Returns:
field value
Throws:
com.webmbt.MBTException

setData

public boolean setData(java.lang.String dataSetID_p,
                       java.lang.String fieldName_p,
                       java.lang.String value_p)
changes a field in the data set. Only the value in the memory is changed.

Example: "$setData('ds1', 'f1', 'newVal')".

Parameters:
dataSetID_p - data set id
fieldName_p - field name
value_p - new value for the field
Returns:
true if set was performed successfully, else false. For example if an invalid data set id was used, it will return false as it could not find the data set.

findData

public java.lang.Integer findData(java.lang.String dataSetID_p,
                                  java.lang.String fieldNames_p,
                                  java.lang.String compValues_p)
Returns the number of data rows found to match the compValues_p. It also sets the the first row found to be the current row.

Example, "$findData('ds1', 'f1', 'val1')" will return number of rows from data set 'ds1' that has field 'f1' with value of 'val1'.

You may find by multiple columns, for example "$findData('ds1', 'f1;f2', 'val1;val2')" will return the count of rows that match fields f1 and f2 with values val1 and val2 respectively.

Parameters:
dataSetID_p - data set id
fieldNames_p - names of the field that will form the string to match the compValues_p.
compValues_p - string formed to match the return field values as specified in the fieldNames_p.
Returns:
0 for not found or number of rows found.

findDataRowIndex

public java.lang.Integer findDataRowIndex(java.lang.String dataSetID_p,
                                          java.lang.String fieldNames_p,
                                          java.lang.String compValues_p)
Returns the row index of the first data row found that matches the compValues_p. The row index returned can then be used in $getData('ds', 'rowIdx', 'fieldName') method.

Example, "$findDataRowIndex('ds1', 'f1', 'val1')" will return the row index of the first row found with field 'f1' with value of 'val1' in dataset 'ds1'.

You may find by multiple columns, for example "$findData('ds1', 'f1;f2', 'val1;val2')" will return the count of rows that match fields f1 and f2 with values val1 and val2 respectively.

Parameters:
dataSetID_p - data set id
fieldNames_p - names of the field that will form the string to match the compValues_p.
compValues_p - string formed to match the return field values as specified in the fieldNames_p.
Returns:
0 for not found or number of rows found.

getVar

public java.lang.Object getVar(java.lang.String varName_p)
                        throws com.webmbt.MBTException
Returns the value for the varName_p passed in. It first check the user var list, if it's not found, it checks the pat var list.

Example, "$getVar('myVar1')". With release 3.0, you may use token syntax to access system var like "[myVar1]".

Parameters:
varName_p - name of the user variable.
Returns:
value for the variable
Throws:
com.webmbt.MBTException

getVarAllRows

public java.lang.String[] getVarAllRows(java.lang.String varName_p)
returns a field on all rows in the data set, that is, returns a column in the data set.

Example, "$getVarRows('var1')".

Parameters:
varName_p - name of the variable.
Returns:
string representation of the value for the variable. If variable contains an array, the array elements will be strung together using semi-colon ";" as the delimeter.

getVar

public java.lang.String getVar(java.lang.String varName_p,
                               java.lang.String index_p)
Returns the value for the variable at the index passed in.

Example, "$getVar('var1', '2')" to get the 2nd value in the variable.

Parameters:
varName_p - name of the variable.
index_p - 0-based index
Returns:
a string representation of the value for the variable.

setVar

public boolean setVar(java.lang.String varName_p,
                      java.lang.String toValue_p)
               throws java.lang.Exception
returns true if value has changed. It triggers the varChangeListener if value has been changed.

Example: <action code="$setVar('myVar','123')"/>

Parameters:
varName_p - variable name
toValue_p - new value
Returns:
true if the var is set to the value passed in. False if no change.
Throws:
if - the variable has a change listener defined and it errored in the listener.
java.lang.Exception

setVar

public boolean setVar(java.lang.String varName_p,
                      java.lang.String toValue_p,
                      java.lang.String modelName_p)
Sets a variable on a different model execution. If multiple threads were running the specified model, it chooses the first thread to set the variable. The model must be running in the same TO server.

This function requires multiple user session license

Example: $setVar('var2','xyz','Model2')

Parameters:
varName_p -
toValue_p -
modelName_p -
Returns:
true if var is set successfully, false if the var could not be set due to model not running or any other error.

isModelRunning

public boolean isModelRunning(java.lang.String modelName_p)
returns true if the model specified is also running in the same TestOptimal server.

Example: $isModelRunning('model2')

Parameters:
modelName_p - name of the model
Returns:
true or false

setVarRowNum

public void setVarRowNum(java.lang.String varName_p,
                         java.lang.String rowNum_p)
Sets the current row number (subscript) for mbt variable passed in. If index number passed in is not value (less than 0 or greater than the array size), this method returns without performing the request.

Parameters:
varName_p - variable name
rowNum_p - row number 0-based.

getVarRowNum

public int getVarRowNum(java.lang.String varName_p)
Returns the current row number (subscript) of the variable name passed in. It does not check for the existence of the local variable. Therefore, it will return 0 if the variable does not exist.

Parameters:
varName_p -
Returns:

nextVarRow

public int nextVarRow(java.lang.String varName_p)
Advances the variable current row number by 1. Returns 0 if the end is reached.

Parameters:
varName_p -
Returns:

rewindVar

public int rewindVar(java.lang.String varName_p)
sets the current row number for the variable to 0. If variable does not exist or the value list is empty, it return -1.

Example: "$rewindVar('var1')" to rewind the variable 'var1' if it has been set to contain array.

Parameters:
varName_p -

getSysVar

public java.lang.String getSysVar(java.lang.String varName_p)
                           throws java.lang.Exception
Returns value for the system variable. The following system variables are supported: For example "$getSysVar('curStateID')" returns the ID of the current state. With release 3.0, you may use token syntax to access system var like [curStateID].

Throws:
java.lang.Exception

getSysVar

public java.lang.String getSysVar(java.lang.String varName_p,
                                  java.lang.String param_p)
                           throws java.lang.Exception
returns system variable that requires a parameter.

Parameters:
varName_p - name of the variable
param_p - parameter
Throws:
java.lang.Exception

getPathVar

public java.lang.Object getPathVar(java.lang.String varName_p)
                            throws com.webmbt.MBTException
retrieve a variable from the current traversal path.

Example: $getPathVar('messageTriggered')

Throws:
com.webmbt.MBTException
Since:
3.2.20

clearAllPathVars

public void clearAllPathVars()
                      throws com.webmbt.MBTException
clears all variables on the current traversal path.

Example: $getPathVar('messageTriggered')

Throws:
com.webmbt.MBTException
Since:
3.2.20

setPathVar

public void setPathVar(java.lang.String varName_p,
                       java.lang.String varVal_p)
                throws com.webmbt.MBTException
sets a specific traversal path variable to the value passed in. Traversal vars are carried over along the traversal path. Duplicate variables are merged by randomly choosing a value from the multiple traversal paths being merged.

Example: $setPathVar('msgTriggerred','packet1')

Throws:
com.webmbt.MBTException
Since:
3.2.20

setPathVarObj

public void setPathVarObj(java.lang.String varName_p,
                          java.lang.Object varVal_p)
                   throws com.webmbt.MBTException
Throws:
com.webmbt.MBTException

date

public java.lang.String date()
                      throws com.webmbt.MBTException
returns todays date string in standard format: MM/dd/yyyy.

Throws:
com.webmbt.MBTException
Since:
2.16

date

public java.lang.String date(java.lang.String dateExpr_p)
                      throws com.webmbt.MBTException
returns a date string in standard format MM/dd/yyyy. Supports several variation of date expressions: today, yesterday, tomorrow, +1D, -1D, +1M, -1M, +1Y, -1Y. For example "$date('-1D')" returns yesterday's date.

Parameters:
dateExpr_p - date expression as described above.
Throws:
com.webmbt.MBTException
Since:
2.16

time

public java.lang.String time()
                      throws com.webmbt.MBTException
returns current time in string in standard time format MM/dd/yyyy HH:mm.

Throws:
com.webmbt.MBTException
Since:
2.16

time

public java.lang.String time(java.lang.String timeExpr_p)
                      throws com.webmbt.MBTException
returns time in a string in standard time format MM/dd/yyyy HH:mm. Supports several variation of time expression: +1H, -1H, -10M, +10M. For example "$time('+1H')" will return time 1 hour from now.

Parameters:
timeExpr_p - time expression as described above.
Throws:
com.webmbt.MBTException

date

public java.lang.String date(java.lang.String dateExpr_p,
                             java.lang.String dateFmr_p)
                      throws com.webmbt.MBTException
returns a date string in java date format specified. Supports several variation of date expressions: today, yesterday, tomorrow, +1D, -1D, +1M, -1M, +1Y, -1Y.

Parameters:
dateExpr_p - date expression as described above.
dateFmr_p - date format to be used to format the date into string. Accept java date simple date format, for example "MM/dd/yyyy". You may also use "epoch" as the format string to retrieve date in number of milliseconds since Jan. 1, 1970 (epoch time).
Throws:
com.webmbt.MBTException
Since:
2.16
See Also:
http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

time

public java.lang.String time(java.lang.String timeExpr_p,
                             java.lang.String timeFmt_p)
                      throws com.webmbt.MBTException
returns a time string in java date/time format specified. Supports several variation of time expression: +1H, -1H, -10M, +10M.

Parameters:
timeExpr_p - time expression as described above.
timeFmt_p - date/time format to be used to format the date/time into string. Accept java date simple date format, for example "MM/dd/yyyy hh:mm:ss". You may also use "epoch" as the format string to retrieve date in number of milliseconds since Jan. 1, 1970 (epoch time).
Throws:
com.webmbt.MBTException
Since:
2.16
See Also:
http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

rand

public float rand()
           throws java.lang.Exception
returns a random number in float between 0 (inclusive) and 1 (exclusive).

Throws:
java.lang.Exception
Since:
2.16

rand

public int rand(java.lang.String limit_p)
         throws java.lang.Exception
returns a random integer number between 0 (inclusive) and limit_p (exclusive).

Example: $rand('10')

Parameters:
limit_p - upper limit (excluded)
Throws:
java.lang.Exception
Since:
2.16

rand

public int rand(java.lang.String startInt_p,
                java.lang.String endInt_p)
         throws java.lang.Exception
returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).

Example, "$rand('2', '5')" to return a random integer of 2, 3, or 4.

Parameters:
startInt_p - min value inclusive
endInt_p - max value exlusive
Throws:
java.lang.Exception
Since:
2.16

rand

public java.lang.String rand(java.lang.String startNum_p,
                             java.lang.String endNum_p,
                             java.lang.String precisionDigit_p)
                      throws java.lang.Exception
returns a random integer number between startInt_p (inclusive) and endInt_p (exclusive).

Example:

Parameters:
startInt_p - min value inclusive
endInt_p - max value exlusive
precisionDigit_p - number of significant digit after decimal point. 0 for integer.
Throws:
java.lang.Exception
Since:
2.16

randBool

public boolean randBool()
                 throws java.lang.Exception
returns a randomly chosen true or false.

Returns:
true or false with equal probability.
Throws:
java.lang.Exception
Since:
3.3.6

seqout

public void seqout(java.lang.String seqText_p)
writes a message to seq.out (SeqOut) file in the model folder. This is an alternative to <seqout> tag.

Example, "$seqout('myVar = [quot][curStateID][quot]')" will write the following to seq.out

myVar = "LoginPage"
if the current state id is at "LoginPage".

The alternative is to use <seqout> tag as follows to generate the same output in seq.out:

                        <seqout>
                                <output>
                                        myVar = "[curStateID]"
                                </output>
                        </seqout>
                

Parameters:
seqText_p - text to be written to seq.out
Throws:
java.lang.Exception - on any i/o error
Since:
3.0

push

public void push(java.lang.String varName_p,
                 java.lang.String value_p)
          throws java.lang.Exception
push a value into a stack variable.

Example, "$push('myStack', 'xx')" will push 'xx' to the end of list of values for 'myStack'. You will then use "$pop('myStack')" to retrieve the last value in the stack.

Parameters:
varName_p - name of the variable.
value_p - value to be pushed to the stack.
Throws:
java.lang.Exception - if the inconsitent use of the variable. That is, if the variable was previous used as a single string variable.
Since:
3.0

pop

public java.lang.String pop(java.lang.String varName_p)
                     throws java.lang.Exception
pops the last value from stack.

Example, "$pop('myStack')".

Parameters:
varName_p - name of the stack variable.
Throws:
java.lang.Exception - on inconsistent use of the stack variable, for example the variable was previously used as a single variable.
Since:
3.0

peek

public java.lang.String peek(java.lang.String varName_p)
                      throws java.lang.Exception
peeks the last value in stack without pop it.

Example, "$peek('myStack')" to retrieve the last value in the stack but does not pop the last value out of the stack.

Parameters:
varName_p - name of the variable.
Throws:
java.lang.Exception - on inconsistent use of the stack variable, for example the variable was previously used as a single variable.
Since:
3.0

popAll

public void popAll(java.lang.String varName_p)
clears the stack.

Parameters:
varName_p -
Since:
3.0

increment

public java.lang.String increment(java.lang.String varName_p,
                                  java.lang.String delta_p)
                           throws java.lang.Exception
increment the variable by the delta passed in.

Usage: <action code="$increment('countVar', '2')"/> increment var countVar by 2.

Specify negative number to decrement.

Parameters:
varName - variable name
delta_p - integer
Throws:
java.lang.Exception
Since:
3.0

increment

public java.lang.String increment(java.lang.String varName_p)
                           throws java.lang.Exception
increments the variable by 1.

Usage: <action code="$increment('countVar')"/>

Parameters:
varName_p - variable name
Throws:
java.lang.Exception
Since:
3.0

decrement

public java.lang.String decrement(java.lang.String varName_p)
                           throws java.lang.Exception
decrement the variable by 1.

Usage: <action code="$decrement('countVar')"/>

Parameters:
varName_p - variable name
Throws:
java.lang.Exception
Since:
3.0

trace

public java.lang.String trace(java.lang.String maxLogCount_p)
                       throws java.lang.Exception
returns the trace in a string of last maxLogCount_p traversals leading up to the current state/transition.

Usage: place in onException or onError in <log> tag to print out trace of what sequence of states and transitions that led to the current state/transition where the error/failure occurred.

Parameters:
maxLogCount_p - max number of traversals
Returns:
String, example output as follows (timestamp: type state/trans id(uid: #)):

06:09:57.609:State Checkout(uid:104)
06:09:57.609:Transition ContinueShopping(uid:115)
06:09:57.656:State ProductList(uid:101)

Throws:
java.lang.Exception
Since:
3.0

getPluginID

public java.lang.String getPluginID()
returns ID of the plugin currently selected for the model. This is equivalent to system var [plugin].

Returns:
SELENIUM, HTMLUNIT, JAVAPLUGIN, etc.
Since:
3.0

getBrowser

public java.lang.String getBrowser()
returns browser set for the model.

Returns:
iexplore, firefox, custom, konqueror, chrome, safari, opera, etc.
Since:
3.0

getBrowserVersion

public java.lang.String getBrowserVersion()
returns version number of the brower set for the model, for example IE 7 it will return "7".

Returns:
version number applicable to the browser set for the model
Since:
3.0
See Also:
getBrowser()

sendMail

public void sendMail(java.lang.String fromAddress,
                     java.lang.String toAddress,
                     java.lang.String subject,
                     java.lang.String messageText)
              throws com.webmbt.MBTException
send mail. Requires javaMail setup in system config (smtp mail host).

Parameters:
fromAddress - from address, if null passed, it will use the from address in system config for javaMail
toAddress - to address
subject - subject text
messageText - message body text
Throws:
com.webmbt.MBTException
Since:
3.0.9

callURL

public java.lang.String callURL(java.lang.String urlString_p)
calls the url passed in and returns the content returned from the url.

Parameters:
urlString_p -
Returns:
url content. if errored, return ERROR: error msg
Since:
3.0.12

execSQL

public java.lang.String execSQL(java.lang.String dbID_p,
                                java.lang.String sqlStmt_p,
                                java.lang.String colName_p,
                                java.lang.String delimeter_p)
                         throws java.lang.Exception
executes an SQL statement and return the result from the specified column name with rows separated by the delimited specified

Parameters:
dbID_p - db id defined in mScript db tag
sqlStmt_p - sql statement, insert, update, stored procedure call, etc.
colName_p - name of the column to return, only used for select statement. pass "" for other statements.
delimeter_p - row delimited to be used to seperate values from different rows, only used for select.
Returns:
# of rows affected for insert/update/delete, status return from stored procedure or column values for select.
Throws:
java.lang.Exception
Since:
3.0.12

sleep

public void sleep(java.lang.String millis_p)
           throws java.lang.Exception
sleeps for number of milliseconds.

Throws:
java.lang.Exception
Since:
3.0.12

addTagCheck

public void addTagCheck(java.lang.String tag_p,
                        java.lang.String passed_p,
                        java.lang.String msg_p)
                 throws java.lang.Exception
adds a tag check/validation message to the tag stat. A tag check/validation usually is a result of an assert. A tag may have many checks/validations per traversal of the state/transition which the tag is assigned to. Each check/validation may pass or fail. When failed, the message will be added to the tag stats to be tallied.

Parameters:
tag_p - one single tag id
passed_p - "Y" or "pass" for passed, "N" or "fail" for failed
msg_p - message to be added to this check.
Throws:
java.lang.Exception
Since:
3.0.12

evalGuard

public boolean evalGuard(com.webmbt.scxml.TransitionNode transObj_p)
                  throws java.lang.Exception
INTERNAL USE ONLY evaluates the guard condition of the transition passed in.

Parameters:
transObj_p -
Returns:
true if guard condition is not specified (null) or evaluates to true.
Throws:
java.lang.Exception
Since:
3.0.16

gotoState

public void gotoState(java.lang.String gotoStateID_p)
               throws java.lang.Exception
requests next state be set to the state id specified.

Parameters:
stateID_p - id of the goto state
Throws:
java.lang.Exception - if unknown state
Since:
3.0.16

gotoTrans

public void gotoTrans(java.lang.String gotoTransStateID_p,
                      java.lang.String gotoTransID_p)
               throws java.lang.Exception
requests the transition passed in be performed next.

Parameters:
stateID_p - id of the source state of the new transition
transID_p - id of the goto transition
Throws:
java.lang.Exception - if unknown state/transition
Since:
3.0.16

getSysConfig

public java.lang.String getSysConfig(java.lang.String propertyName_p)
returns the property value from the system config.

Parameters:
propertyName_p - name of the property
Returns:
null/blank if property does not exist.
Since:
3.0.16

getSysConfig

public java.lang.String getSysConfig(java.lang.String propertyName_p,
                                     java.lang.String defaultValue_p)
returns the property value from the system config. If property does not exist, return the defaultValue_p passed in.

Parameters:
propertyName_p - name of the property
Since:
3.0.16

useSeqOutPlugin

public boolean useSeqOutPlugin()
INTERNAL USE ONLY

Returns:

getSeqOutPlugin

public SeqOutPlugin getSeqOutPlugin()
INTERNAL USE ONLY

Returns:

resetSeqNum

public void resetSeqNum()
resets the seqNum sys var to 0.


checkSeqNum

public java.lang.String checkSeqNum()
returns the current seqNum without incrementing it.

Example: $checkSeqNum()


setSeqNum

public void setSeqNum(java.lang.String seqNum_p)
sets sys var seqNum to the value specified.

Example: $setSeqNum('10') to set the sequence number to 10.

Parameters:
seqNum_p -

and

public boolean and(java.lang.String expr1_p,
                   java.lang.String expr2_p)
            throws java.lang.Exception
performs AND operation on the two mScript expressions passed in and returns a true if both expressions evaluate to true, else return false.

Example: $and('[seqNum] gt 1', '[seqNum] lt 10'), which returns true when either seqNum var is greater than 1 and less than 10.

Parameters:
expr1_p -
expr2_p -
Returns:
Throws:
java.lang.Exception
Since:
3.1.6

and

public boolean and(java.lang.String expr1_p,
                   java.lang.String expr2_p,
                   java.lang.String expr3_p)
            throws java.lang.Exception
performs AND operation on the three mScript expressions passed in and returns a true if all expressions evaluate to true, else return false.

Example: $and('[var2] ge [var3]','$getData('ds1','f1')','[var34] between [var1],[var2]')

Parameters:
expr1_p -
expr2_p -
expr3_p -
Returns:
Throws:
java.lang.Exception
Since:
3.1.6

or

public boolean or(java.lang.String expr1_p,
                  java.lang.String expr2_p)
           throws java.lang.Exception
performs OR operation on the two mScript expressions passed in and returns a true if any of the expressions evaluates to true, else return false.

Example: $or('[seqNum] eq 1', '[seqNum] gt 10'), which returns true when either seqNum var is 1 or greater than 10.

Parameters:
expr1_p -
expr2_p -
Returns:
Throws:
java.lang.Exception
Since:
3.1.6

or

public boolean or(java.lang.String expr1_p,
                  java.lang.String expr2_p,
                  java.lang.String expr3_p)
           throws java.lang.Exception
performs OR operation on the three mScript expressions passed in and returns a true if any of the expressions evaluates to true, else return false.

Example: $or('[var1] gt [var2]','[var10 lt [var3]','[var1] contains [var2]')

Parameters:
expr1_p -
expr2_p -
expr3_p -
Returns:
Throws:
java.lang.Exception
Since:
3.1.6

nor

public boolean nor(java.lang.String expr1_p,
                   java.lang.String expr2_p,
                   java.lang.String expr3_p)
            throws java.lang.Exception
performs NOR on the expression list passed. blank exprs are ignored.

Parameters:
exprList_p - list of expressions in string array.
Throws:
java.lang.Exception
Since:
3.1.19

nor

public boolean nor(java.lang.String expr1_p,
                   java.lang.String expr2_p)
            throws java.lang.Exception
Throws:
java.lang.Exception

nand

public boolean nand(java.lang.String expr1_p,
                    java.lang.String expr2_p,
                    java.lang.String expr3_p)
             throws java.lang.Exception
performs NAND on the expression list passed. blank exprs are ignored.

Parameters:
exprList_p - list of expressions in string array.
Throws:
java.lang.Exception
Since:
3.1.19

nand

public boolean nand(java.lang.String expr1_p,
                    java.lang.String expr2_p)
             throws java.lang.Exception
Throws:
java.lang.Exception

xor

public boolean xor(java.lang.String expr1_p,
                   java.lang.String expr2_p,
                   java.lang.String expr3_p)
            throws java.lang.Exception
performs XOR on the expression list passed. blank exprs are ignored.

Parameters:
exprList_p - list of expressions in string array.
Throws:
java.lang.Exception
Since:
3.1.19

xor

public boolean xor(java.lang.String expr1_p,
                   java.lang.String expr2_p)
            throws java.lang.Exception
Throws:
java.lang.Exception

compare

public boolean compare(java.lang.String expr1_p,
                       java.lang.String op_p,
                       java.lang.String expr2_p)
                throws java.lang.Exception
performs comparison between two expressions passed in using the operator specified.

Example: $compare('[var1]','eq','[var2]') to compare the values in var1 and var2 and return the true if they are equal.

Parameters:
expr1_p -
op_p -
expr2_p -
Returns:
Throws:
java.lang.Exception
Since:
3.1.6

isTrue

public boolean isTrue(java.lang.String expr_p)
               throws java.lang.Exception
evaluates the mScript expression and return true if the result is one of the representation of Boolean true: true, T, 1, yes, Y, etc. All other values are evaluated to false.

Example: $isTrue('[var2]')

Parameters:
expr1_p - any mScript expression
Returns:
true or false
Throws:
java.lang.Exception
Since:
3.1.6

isFalse

public boolean isFalse(java.lang.String expr_p)
                throws java.lang.Exception
evaluates the mScript expression and return the negation of the boolean result from the expression. This function is the same as $not(expr)

Example: $isFalse('[var2]')

Parameters:
expr1_p - any mScript expression
Returns:
true or false
Throws:
java.lang.Exception
Since:
3.1.7
See Also:
not(expr)

not

public boolean not(java.lang.String expr_p)
            throws java.lang.Exception
evaluates the mScript expression and return the negation of the boolean result from the expression. This function is the same as $isFalse(expr).

Example: $not('[var2] eq $getData('ds1','f1')')

Parameters:
expr1_p - any mScript expression
Returns:
true or false
Throws:
java.lang.Exception
Since:
3.1.7
See Also:
ifFalse(expr)

ifTrueMsg

public java.lang.String ifTrueMsg(java.lang.String expr_p,
                                  java.lang.String msg_p)
                           throws java.lang.Exception
evaluates the expression passed in, if the expression evaluates to true, it returns the message expression (may contain other mScript function calls). Otherwise, it returns blank.

Example: $ifTrueMsg('[var1] gt 5', 'variable var1 is greater than 5'), which returns the message 'variable var1 is greater than 5' when the variable 'var1' has a value greater than 5.

Parameters:
expr_p -
msg_p -
Returns:
Throws:
java.lang.Exception
Since:
3.1.7

ifFalseMsg

public java.lang.String ifFalseMsg(java.lang.String expr_p,
                                   java.lang.String msg_p)
                            throws java.lang.Exception
evaluates the expression passed in, if the expression evaluates to false, it returns the message expression (may contain other mScript function calls). Otherwise, it returns blank.

Example: $ifFalseMsg('[var1] gt 5', 'variable var1 is greater than 5'), which returns the message 'variable var1 is greater than 5' when the variable 'var1' has a value greater than 5.

Parameters:
expr_p -
msg_p -
Returns:
Throws:
java.lang.Exception
Since:
3.1.7

chooseMsg

public java.lang.String chooseMsg(java.lang.String expr_p,
                                  java.lang.String trueMsg_p,
                                  java.lang.String falseMsg_p)
                           throws java.lang.Exception
evaluates the expression passed in, if the expression evaluates to true, it returns the value from the trueMsg_p expression (may contain other mScript function calls). Otherwise, it returns the value from the falseMsg_p expression.

Example: $chooseMsg('[var1] gt 5', 'variable var1 is greater than 5', 'variable var1 is less than or equal to 5'), which returns the message 'variable var1 is greater than 5' when the variable 'var1' has a value greater than 5, else it returns the second message.

Parameters:
expr_p -
trueMsg_p -
falseMsg_p -
Returns:
value from either trueMsg_p or falseMsg_p expression
Throws:
java.lang.Exception
Since:
3.1.7

evalExpr

public java.lang.String evalExpr(java.lang.String expr_p)
                          throws java.lang.Exception
performs mScript expression evaluation.

Parameters:
expr_p -
Returns:
Throws:
java.lang.Exception
Since:
3.1.7

evalExprToInt

public int evalExprToInt(java.lang.String expr_p)
                  throws java.lang.Exception
performs mScript expression evaluation to an integer. default to 0 if expr is evaluated to blank or null or invalid integer.

Parameters:
expr_p -
Returns:
Throws:
java.lang.Exception
Since:
3.2.17

getVarList

public java.util.HashMap<java.lang.String,java.lang.Object> getVarList()

getPluginMgr

public PluginMgr getPluginMgr()

add

public java.lang.String add(java.lang.String expr1,
                            java.lang.String expr2)
                     throws java.lang.Exception
add two exprs.

Usage: <action code="$add('$getVar('a')', '2')"/>

Parameters:
expr1 -
expr2 -
Throws:
java.lang.Exception
Since:
3.1.19

multiply

public java.lang.String multiply(java.lang.String expr1,
                                 java.lang.String expr2)
                          throws java.lang.Exception
multiply two exprs.

Usage: <action code="$multiply('$getVar('a')', '2')"/>

Parameters:
expr1 -
expr2 -
Throws:
java.lang.Exception
Since:
3.1.19

waitForVarChanged

public java.lang.String waitForVarChanged(java.lang.String varName_p)
                                   throws java.lang.Exception
waits until the variable specified has changed its value and return the new value. No timeout. Use this function to wait for signal from another model. This function is intended to be used as communication between model executions and not within the same model execution in FSM.

In concurrent modeling edition, since the transitions are executed concurrently, you this function can be used as communication between transitions (parallel execution of transitions).

Parameters:
varName_p -
Returns:
new value set for the var.
Throws:
java.lang.Exception

waitForVarChanged

public java.lang.String waitForVarChanged(java.lang.String varName_p,
                                          java.lang.String timeoutMillis_p)
                                   throws java.lang.Exception
waits until the variable specified has changed its value and return the new value. This function waits up to the timeout setting specified and returns "TimedOut" if timeout occurs. Use this function to wait for signal from another model. This function is intended to be used as communication between model executions and not within the same model execution in FSM.

In concurrent modeling edition, since the transitions are executed concurrently, you this function can be used as communication between transitions (parallel execution of transitions).

Parameters:
varName_p -
timeoutMillis_p - timeout in millis
Returns:
"TimedOut" if timeout was triggered, or the actual value.
Throws:
java.lang.Exception

waitForVarChanged

public java.lang.String waitForVarChanged(java.lang.String varName_p,
                                          java.lang.String timeoutMillis_p,
                                          java.lang.String newValue_p)
                                   throws java.lang.Exception
waits until the variable specified has changed its value. No timeout. Use this function to wait for signal from another model. This function is intended to be used as communication between model executions and not within the same model execution in FSM.

In concurrent modeling edition, since the transitions are executed concurrently, you this function can be used as communication between transitions (parallel execution of transitions).

Parameters:
varName_p -
Returns:
new value
Throws:
java.lang.Exception

callFunc

public java.lang.String callFunc(java.lang.String funcName_p,
                                 java.lang.String params_p)
                          throws java.lang.Exception
calls a user function with parameters. Example: $callFunc('perfLogin', 'loginID=user1, password=xyz')

Parameters:
funcName_p - name of the user function. User functions are declared in MBT triggers.
params_p - params in the format of p1=val1,p2=val2,... where p1,p2 are parameter names and val1 and val2 are the values for the parameters.
Returns:
a String set by mscript method $setFuncReturn('val')
Throws:
java.lang.Exception
Since:
3.3.5

callFunc

public java.lang.String callFunc(java.lang.String funcName_p)
                          throws java.lang.Exception
calls a user function without parameters. Example: $callFunc('perfLogin')

Parameters:
funcName_p - name of the user function. User functions are declared in MBT triggers.
Returns:
a String set by mscript method $setFuncReturn('val')
Throws:
java.lang.Exception
Since:
3.3.6

getFuncParam

public java.lang.String getFuncParam(java.lang.String paramName_p)
                              throws java.lang.Exception
returns the param value for the user function in current scope. Should only be called within the scope of a user function or nested mscript tag within the user function.

This function always returns blank when is called from a non-state or transition context, e.g. in Mbt_start. Example: $getFuncParam('loginID')

Parameters:
paramName_p - name of the param.
Returns:
String value of the parameter
Throws:
java.lang.Exception
Since:
3.3.5

listFuncParams

public java.lang.String listFuncParams()
                                throws java.lang.Exception
returns a string that represent parameters. Used to print out the parameters passed to the current user function for debugging or auditing. For example: Parameters are: $listFuncParams()

Returns:
Throws:
java.lang.Exception
Since:
3.3.7

setFuncReturn

public void setFuncReturn(java.lang.String retVal_p)
                   throws java.lang.Exception
sets the return value for the current user function. Example: $setFuncReturn('returnResult')

Parameters:
retVal_p - return value
Throws:
java.lang.Exception
Since:
3.3.7

getTransData

public java.lang.String getTransData(java.lang.String fieldName_p)
                              throws com.webmbt.MBTException
retrieves the DDT field value defined for the current transition.

Parameters:
fieldName_p -
Returns:
Throws:
com.webmbt.MBTException
Since:
3.3.5


Copyright © 2008. All Rights Reserved.