Class VirtualUserScript
- java.lang.Object
-
- com.facilita.fc.runtime.VirtualUserScript
-
- All Implemented Interfaces:
DataDictionary
- Direct Known Subclasses:
EggplantVirtualUserScript
,SeleniumVirtualUserScript
,WebBrowserScript
public abstract class VirtualUserScript extends java.lang.Object implements DataDictionary
TheVirtualUserScript
class is the base class of all eggPlant Performance Script classes. All other Virtual User types are specializations of this class.The script wizards (recorders and generators) create Virtual User Scripts with source code files containing classes whose base class is
VirtualUserScript
or one of its specializations. Many of the operations (methods) ofVirtualUserScript
are delegated to theVirtualUser
class. Access to theVirtualUser
instance can be obtained via thegetVU()
method.All subclasses of
VirtualUserScript
must implement theabstract
methodscript()
, as this is the method which is called when the Virtual User Script is executed during a test. A blankscript()
method is created when a Virtual User Script is created in eggPlant Performance Studio.
-
-
Field Summary
Fields Modifier and Type Field Description protected CustomCancellationToken
ct
A helper object used to communicate between main and foreground scripts.protected boolean
isMainScript
Internal use only.
-
Constructor Summary
Constructors Constructor Description VirtualUserScript()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
acceptCancellation()
Called to accept the script response to the requested cancellation.void
add(DataDictionary d)
Merges the specifiedDataDictionary
into thisDataDictionary
.protected boolean
checkIfCancellationRequested()
For internal use only.void
clearProgressPoint()
Clears the current progress point set for this Virtual User.void
createBackgroundScript(java.lang.String id, java.lang.String vuScriptClassName)
Creates a new background script and starts it.void
createBackgroundScript(java.lang.String id, java.lang.String vuScriptClassName, AutomaticStopCriteria stopCriterion, java.util.EnumSet<ExecutionFlags> executionFlags, java.time.Duration pauseBetweenScriptsLoops, java.time.Duration autoStopTimeout)
Creates a new background script and starts it if requested.void
endRequest(java.lang.String request)
For internal use only.void
endRequest(java.lang.String request, MetricCollection metrics)
For internal use only.void
endTiming(java.lang.String id)
Writes an end timing event to the VU event log.void
endTiming(java.lang.String id, boolean pass)
Writes an end timing event to the VU event log, specifying whether the timing passed.int
endTransaction(java.lang.String id)
Writes an end transaction event to the VU event log.int
endTransaction(java.lang.String id, boolean pass)
Writes an end transaction event to the VU event log, specifying whether the transaction passed.int
endTransaction(java.lang.String id, boolean pass, java.lang.String tag)
Writes an end transaction event to the VU event log, specifying whether the transaction passed, and specifying atag
which appears in the Info column.void
error(java.lang.Exception e)
Writes an error message to the VU event log, which will consist of the details of the specified Exception.void
error(java.lang.String info)
Writes an error message to the VU event log.void
error(java.lang.String message, java.lang.Exception e)
Writes an error message to the VU event log, which will include the stack trace of the specifiedException
.void
error(java.lang.String id, java.lang.String info)
Writes an error message to the VU event log, specifying an identifier which appears in the ID column.void
error(java.lang.String id, java.lang.String info, java.lang.String imagePath)
Writes an error message and an image link to the VU event log, specifying an identifier which appears in the ID column.void
exitVU()
Stops execution of this Virtual User.void
exitVU(boolean pass)
Stops execution of this Virtual User, specifying whether the script completed successfully.void
exitVU(java.lang.String msg, boolean pass)
Stops execution of this Virtual User, specifying whether the script completed successfully and a message to display at the end of the event log.void
fail(java.lang.String message, boolean throwException)
Writes a fail event to the VU event log.void
failTiming(java.lang.String id)
Writes a fail timing event to the VU event log.int
failTransaction(java.lang.String id)
Writes a fail transaction event to the VU event log.int
failTransaction(java.lang.String id, java.lang.String tag)
Writes a fail transaction event to the VU event log, specifying atag
which appears in the Info column.void
finalSequence()
Stops execution of the current script and then executes the scripts in the final section of the current workflow.void
finishIterating()
Prevents further iterations of the iterated sequence of scripts for this Virtual User.boolean
finishIteratingRequested()
Returnstrue
if this Virtual User has been requested to finish iterating.void
flushEventLog()
Flushes the event log to disk.static java.lang.String
formatDateTime(java.lang.String format)
Converts the current date/time to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.Duration offset)
Converts the current date/time, offset by a specified Duration, to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.Duration offset, java.time.ZoneId timezone)
Converts the current date/time to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.Duration offset, java.time.ZoneId timezone, java.util.Locale locale)
Converts the current date/time to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.Duration offset, java.util.Locale locale)
Converts the current date/time to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime)
Converts a LocalDateTime object to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.Duration offset)
Converts a LocalDateTime object to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.Duration offset, java.time.ZoneId timezone)
Converts a LocalDateTime object to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.Duration offset, java.time.ZoneId timezone, java.util.Locale locale)
Converts a LocalDateTime object to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.Duration offset, java.util.Locale locale)
Converts a LocalDateTime object to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.ZoneId timezone)
Converts a LocalDateTime object to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.ZoneId timezone, java.util.Locale locale)
Converts a LocalDateTime object to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.util.Locale locale)
Converts a LocalDateTime object to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.ZoneId timezone)
Converts the current date/time to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.time.ZoneId timezone, java.util.Locale locale)
Converts the current date/time to its equivalent string representation using the specified format.static java.lang.String
formatDateTime(java.lang.String format, java.util.Locale locale)
Converts the current date/time to its equivalent string representation using the specified format.<T> T
get(java.lang.String key)
Returns a reference to anObject
held in the dictionary.java.lang.Object
get(java.lang.String key, java.lang.Object defaultValue)
Returns anObject
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.java.lang.String
getBackgroundScriptID()
Gets the script ID, which was provided when this script was started as a background script.java.util.List<java.lang.String>
getBackgroundScriptIDs()
Returns a list of currently registered wtih the VU background script IDs.ScriptStatus
getBackgroundScriptStatus(java.lang.String id)
Returns a status of the given background script.boolean
getBoolean(java.lang.String key)
Returns aboolean
value held in the dictionary.boolean
getBoolean(java.lang.String key, boolean defaultValue)
Returns aboolean
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.int
getCurrentIteration()
Gets the number of the iteration that this Virtual User is currently executing (beginning at 1).static javax.xml.datatype.XMLGregorianCalendar
getCurrentTimeInXml()
java.lang.String
getCurrentTransaction()
Gets the name of the transaction that is currently in progress.DataDictionary
getDataDictionary()
Gets the Data Dictionary belonging to thisVirtualUser
.DataDictionary
getDataDictionary(java.lang.String key)
Gets the Data Dictionary named with the specifiedkey
and assigned to the Virtual User in eggPlant Performance Studio.java.lang.String
getDataPath()
Gets the path to the data folder.DataTable
getDataTable(java.lang.String key)
Gets the specified Data Table.double
getDouble(java.lang.String key)
Returns adouble
value held in the dictionary.double
getDouble(java.lang.String key, double defaultValue)
Returns adouble
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.int
getElapsedTime()
Gets the elapsed time since the beginning of the test, in milliseconds.java.lang.String
getFilesDataPath()
Gets the path of thedata\Files
folder.float
getFloat(java.lang.String key)
Returns afloat
value held in the dictionary.float
getFloat(java.lang.String key, float defaultValue)
Returns afloat
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.int
getGroupSize()
Gets the number of Virtual Users in the group that this Virtual User belongs to.int
getGroupSize(java.lang.String groupName)
Gets the number of Virtual Users in the specified Virtual User group.com.facilita.fc.runtime.SimpleDataDictionary
getGroupSizes()
Gets the number of Virtual Users in each Virtual User group.int
getIndex()
Gets the index number of this Virtual User within the Virtual User group that it belongs to.int
getInitialDelay()
Gets the initial delay for this Virtual User, between the start of the test and the start of the first script execution.java.lang.String
getInjectorFamilyName()
Returns the injector family namejava.lang.String
getInjectorName()
Returns the injector machine nameint
getInt(java.lang.String key)
Returns anint
value held in the dictionary.int
getInt(java.lang.String key, int defaultValue)
Returns anint
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.java.lang.Integer
getInteger(java.lang.String key)
Returns ajava.lang.Integer
value held in the dictionary.java.lang.Integer
getInteger(java.lang.String key, java.lang.Integer defaultValue)
Returns ajava.lang.Integer
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.protected boolean
getIsStopped()
Internal use only.int
getIteration()
Gets the number of the iteration that this Virtual User is currently executing (beginning at 0).int
getIterationDelay()
Gets the delay time in milliseconds between iterations of the repeated sequence of scripts.int
getIterationForTime()
Gets the time in milliseconds that the iterated sequence of scripts will iterate for.java.lang.String
getLastError()
Gets the most recent error encountered by this Virtual User.java.lang.String
getLastTransaction()
Gets the name of the most recent transaction to have ended.java.util.List
getList(java.lang.String key)
Returns aList
value held in the dictionary.java.util.List
getList(java.lang.String key, java.util.List defaultList)
Returns aList
value held in the dictionary, or thedefaultList
if thekey
cannot be found.long
getLong(java.lang.String key)
Returns along
value held in the dictionary.long
getLong(java.lang.String key, long defaultValue)
Returns along
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.java.util.Map
getMap()
Gets aMap
containing all the keys/values in this dictionary.int
getMaxFailures()
Gets the maximum number of failures allowed in the script before this Virtual User terminates.static java.lang.String
getMillisecondsSinceEpoch()
static java.lang.String
getMillisecondsSinceEpoch(long offset)
java.lang.String
getName()
Gets the name of this dictionary.int
getNumberOfErrors()
Gets the number of errors that have been reported for this Virtual User.int
getNumberOfFailures()
Gets the current number of script failures for this Virtual User.int
getNumberOfIterations()
Gets the total number of iterations that the repeated sequence of scripts will execute.int
getNumberOfWarmupIterations()
Gets the number of warm-up iterations for this Virtual User.int
getNumberOfWarnings()
Gets the number of warnings that have been reported for this Virtual User.int
getPauseFactor()
Gets the current percentage pause factor.java.lang.String
getProgressPoint()
Gets the text of the most recent progress point that was set.java.lang.String
getRunPath()
Gets the path to the test run results.java.lang.String
getSandboxPath()
Gets the path to the sandbox location.java.lang.String
getScriptName()
Gets the name of this Virtual User Script.static java.lang.String
getSecondsSinceEpoch()
static java.lang.String
getSecondsSinceEpoch(long offset)
com.facilita.fc.runtime.Service
getService(java.lang.Class<com.facilita.fc.runtime.Service> serviceClass)
Get aService
object of the specified typejava.lang.String
getString(java.lang.String key)
Returns aString
value held in the dictionary.java.lang.String
getString(java.lang.String key, java.lang.String defaultValue)
Returns aString
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.int
getTimingElapsedTime()
Gets the elapsed time of the current active timing.TransactionData
getTransactionData(java.lang.String id)
Get data about the specified transaction.int
getTransactionElapsedTime(java.lang.String id)
Gets the current elapsed time of the transaction with the specifiedid
.int
getTransactionElapsedTime(java.lang.String id, java.lang.String tag)
Gets the current elapsed time of the transaction with the specifiedid
andtag
.boolean
getTransactionLoggingOn()
Returnstrue
if transactions should be logged for this VU.int
getUniqueID()
Gets a test-wide unique identifier for this Virtual User.int
getUniqueID(java.lang.String groupName, int index)
Gets a test-wide unique identifier for a specified Virtual User within a Virtual User group.VirtualUser
getVirtualUser()
Gets the current VU instance, as an object of typeVirtualUser
.VirtualUser
getVU()
Gets the current VU instance, as the most specialised subclass ofVirtualUser
.java.lang.String
getVUName()
Gets the name of the group that this Virtual User belongs to.boolean
hasKey(java.lang.String key)
Returnstrue
if the specifiedkey
is contained within the dictionary.boolean
isFinalScript()
Returnstrue
if the current executing script is within the final section of this Virtual User's workflow.boolean
isFirstScript()
Returnstrue
if the current executing script is the first script to be executed.boolean
isInitialScript()
Returnstrue
if the current executing script is within the initial section of this Virtual User's workflow.boolean
isIteratedScript()
Returnstrue
if the current executing script is within the repeated section of this Virtual User's workflow.boolean
isLastIteration()
Returnstrue
if more iterations will occur for the current Virtual User.boolean
isPacing()
Returnstrue
if this Virtual User will adjust the delay between iterations to maintain a steady pace of iterations.boolean
isReadOnly()
Returnstrue
if this dictionary is read-only.java.util.Iterator
keys()
Returns anIterator
that can be used to iterate over the keys in this dictionary.int
lastIterationDelay()
Gets the delay time in milliseconds between the previous iteration and the current iteration.void
logCurrentDataValues()
Write all of the current data values to the VU event logvoid
nextIteration()
Stops execution of the current script, and starts execution of the next iteration.void
nextScript()
Stops execution of the current script, and starts execution of the next script in the sequence.void
nextSequence()
Stops execution of the current script and any other scripts in the current sequence, and starts execution of the next sequence of scripts.protected void
onBackgroundScriptCancellation()
Called when the background script executing in a loop is cancelledint
pause()
Pauses the execution of the script.int
pause(int interval)
Pauses the execution of the script for a specifiedinterval
(modified bygetPauseFactor()
).void
pre()
This method is called just before this script is executed for the first time.void
raiseAlert(int severity, java.lang.String message)
Writes an alert of the specifiedseverity
to the Alerts table in Test Controller.void
recordMetric(java.lang.String name, int value)
Records a user metric.void
recordMetrics(MetricCollection metrics)
Records multiple user metrics simultaneously.void
recordTransaction(java.lang.String id, int startTime, int duration)
Records a transaction in the VU event log.void
recordTransaction(java.lang.String id, int startTime, int duration, boolean pass)
Records a transaction in the VU event log, specifying whether the transaction passed.void
recordTransaction(java.lang.String id, java.util.Date startTime, int duration)
Records a transaction in the VU event log.void
recordTransaction(java.lang.String id, java.util.Date startTime, int duration, boolean pass)
Records a transaction in the VU event log, specifying whether the transaction passed.void
requestToStopBackgroundScript(java.lang.String id)
Requests currently running background script to stop.void
resume()
Resumes the background script (which was previously suspended).void
resumeBackgroundScript(java.lang.String id)
Resumes currently suspended background script.void
resumeTransaction(java.lang.String id)
Resumes the timing of the specified transaction.void
resumeTransaction(java.lang.String id, java.lang.String tag)
Resumes the timing of the specified transaction, identified bytag
as well asid
.abstract void
script()
This is the method which will be run by theVirtualUser
when it executes this script, and is where you should write your test script code.<T> T
selectRandomEntryFromList(java.lang.String key)
Selects a random entry from a list stored in this Virtual User's data dictionary.<T> void
set(java.lang.String key, T o)
Sets anObject
value in the dictionary.protected void
setBackgroundScriptID(java.lang.String backgroundScriptID)
For internal use only.void
setBoolean(java.lang.String key, boolean b)
Sets aboolean
value in the dictionary.void
setCancellationToken(CustomCancellationToken ct)
For internal use only.void
setDouble(java.lang.String key, double i)
Sets adouble
value in the dictionary.void
setFloat(java.lang.String key, float i)
Sets afloat
value in the dictionary.void
setInt(java.lang.String key, int i)
Sets anint
value in the dictionary.void
setInteger(java.lang.String key, java.lang.Integer i)
Sets anInteger
value in the dictionary.void
setList(java.lang.String key, java.util.List list)
Sets aList
value in the dictionary.void
setLong(java.lang.String key, long i)
Sets along
value in the dictionary.void
setName(java.lang.String name)
Sets the name of this dictionary.void
setNumberOfWarmupIterations(int numberOfWarmupIterations)
Sets the number of warm-up iterations for this Virtual User.void
setPauseFactor(int pauseFactor)
Sets the current percentage pause factor.void
setProgressPoint(java.lang.String progressPoint)
Sets a progress point in the VU event log.void
setProgressPoint(java.lang.String progressPoint, boolean pass)
Sets a progress point in the VU event log, specifying whether the progress point passed.void
setProgressPoint(java.lang.String progressPoint, java.lang.String info, boolean pass)
Sets a progress point in the VU event log, specifying whether the progress point passed and specifying extra information which appears in the Info column.void
setString(java.lang.String key, java.lang.String string)
Sets aString
value in the dictionary.void
setSynchronizationPoint(java.lang.String id)
Set a named synchronization point.void
setTransactionLoggingOn(boolean value)
Sets whether transactions should be logged for this VU.void
startBackgroundScript(java.lang.String id)
Starts previously created and not started background scriptvoid
startRequest(java.lang.String request)
For internal use only.void
startTiming(java.lang.String id)
Writes a start timing event to the VU event log.void
startTransaction(java.lang.String id)
Writes a start transaction event to the VU event log.void
startTransaction(java.lang.String id, java.lang.String tag)
Writes a start transaction event to the VU event log, specifying atag
which appears in the Info column.void
stopBackgroundScriptImmediately(java.lang.String id)
Tells the script to stop immediately.void
stopImmediately()
Internal use only.void
suspend()
Asks the background script to suspend.void
suspendBackgroundScript(java.lang.String id)
Suspends currently executing background script.void
suspendTransaction(java.lang.String id)
Suspends the timing of the specified transaction.void
suspendTransaction(java.lang.String id, java.lang.String tag)
Suspends the timing of the specified transaction, identified bytag
as well asid
.int
timeToPause(int interval)
Gets the length of time that this Virtual User would pause for ifpause(int)
were called with the specifiedinterval
.java.lang.String
toString()
Returns aString
representation of the dictionary.protected void
tryToSuspend()
Try to suspend a background script.void
unsetSynchronizationPoint(java.lang.String id)
Unset a named synchronization point.boolean
verify(boolean arg, boolean throwException)
Verifies that a boolean expression istrue
.boolean
verifyEQ(double arg1, double arg2, double delta, boolean throwException)
Verifies that two doubles are equal.boolean
verifyEQ(int arg1, int arg2, boolean throwException)
Verifies that two integers are equal.boolean
verifyEQ(long arg1, long arg2, boolean throwException)
Verifies that two longs are equal.boolean
verifyEQ(java.lang.String arg1, java.lang.String arg2, boolean throwException, boolean caseInsensitive)
Verifies that twoString
objects are equal.boolean
verifyLE(double arg1, double arg2, double delta, boolean throwException)
Verifies that one double is less than or equal to another.boolean
verifyLE(int arg1, int arg2, boolean throwException)
Verifies that one integer is less than or equal to another.boolean
verifyLE(long arg1, long arg2, boolean throwException)
Verifies that one long is less than or equal to another.boolean
verifyLE(java.lang.String arg1, java.lang.String arg2, boolean throwException, boolean caseInsensitive)
Verifies that oneString
is less than or equal to another.boolean
verifyLT(double arg1, double arg2, double delta, boolean throwException)
Verifies that one double is less than another.boolean
verifyLT(int arg1, int arg2, boolean throwException)
Verifies that one integer is less than another.boolean
verifyLT(long arg1, long arg2, boolean throwException)
Verifies that one long is less than another.boolean
verifyLT(java.lang.String arg1, java.lang.String arg2, boolean throwException, boolean caseInsensitive)
Verifies that oneString
is less than another.<T> T
waitFor(java.lang.String key, long timeout)
Returns a reference to an object stored in the data dictionary.void
waitForBackgroundScriptToFinish(java.lang.String id, java.time.Duration timeout)
Waits for the background script to finish work in the given timeout, if timeout is not provided or null it waits until the tasks finish (if at all), if timeout is not null, then it returns false if it expired before the timeout reached.boolean
waitForBoolean(java.lang.String key, long timeout)
Returns a boolean stored in the data dictionary.double
waitForDouble(java.lang.String key, long timeout)
Returns a double stored in the data dictionary.float
waitForFloat(java.lang.String key, long timeout)
Returns a float stored in the data dictionary.int
waitForInt(java.lang.String key, long timeout)
Returns an int stored in the data dictionary.java.util.List
waitForList(java.lang.String key, long timeout)
Returns a reference to a List stored in the data dictionary.long
waitForLong(java.lang.String key, long timeout)
Returns a long stored in the data dictionary.java.lang.String
waitForString(java.lang.String key, long timeout)
Returns a reference to a String stored in the data dictionary.void
waitForSynchronizationPoint(java.lang.String id, long timeoutMilliseconds)
Wait for a named synchronization point to be set.void
warn(java.lang.Exception e)
Writes a warning message to the VU event log, consisting of the specified exceptionvoid
warn(java.lang.String info)
Writes a warning message to the VU event log.void
warn(java.lang.String id, java.lang.String info)
Writes a warning message to the VU event log, specifying an identifier which appears in the ID column.void
warn(java.lang.String id, java.lang.String info, java.lang.String imagePath)
Writes a warning message and an image link to the VU event log, specifying an identifier which appears in the ID column.java.lang.String
whereAmI()
Returns a stack trace for this Virtual User.void
writeMessage(java.lang.Exception e)
Write an information message to the VU event log, consisting of the exception specified.void
writeMessage(java.lang.String message)
Writes an information message to the VU event log.void
writeMessage(java.lang.String id, java.lang.String message)
Writes an information message to the VU event log, specifying an identifier which appears in the ID column.void
writeMessage(java.lang.String id, java.lang.String info, java.lang.String imagePath)
Writes an information message to the VU event log and also a link to an image, specifying an identifier which appears in the ID column.void
writeSystemLog(java.lang.String message)
Writes an alert of Error severity to the Alerts table in Test Controller.void
writeSystemLog(java.lang.String heading, java.lang.String message)
Writes an alert of Error severity to the Alerts table in Test Controller, specifying aheading
to prefix to themessage
.
-
-
-
Field Detail
-
isMainScript
protected boolean isMainScript
Internal use only.
-
ct
protected CustomCancellationToken ct
A helper object used to communicate between main and foreground scripts. Background script is normally use it to check to see if it needs to exit.
-
-
Method Detail
-
script
public abstract void script() throws java.lang.Exception
This is the method which will be run by theVirtualUser
when it executes this script, and is where you should write your test script code.This is an
abstract
method and must be overridden in subclasses ofVirtualUserScript
. In scripts created using eggPlant Performance Studio, a blankscript()
method is automatically added.If this script is assigned to a Virtual User group in a test, or is part of a workflow that is assigned to a Virtual User group in a test, then the script will be executed when the test is run.
If this Virtual User (along with any others in the group) is assigned a single script, then the
script()
method of the VirtualUserScript object is called once per iteration.If this Virtual User (along with any others in the group) is assigned a workflow, then the point at which the
script()
method is called depends on which section of the workflow the script is in.- initial sequence of scripts: the
script()
method of eachVirtualUserScript
object is called once at the beginning of the test, in the order in which the scripts appear in the sequence. - repeated sequence of scripts: the
script()
method of eachVirtualUserScript
object is called once per iteration, in the order in which the scripts appear in the sequence. - final sequence of scripts: the
script()
method of eachVirtualUserScript
object is called once at the end of the test, in the order in which the scripts appear in the sequence.
- Throws:
java.lang.Exception
- An error occurred
- initial sequence of scripts: the
-
pre
public void pre() throws java.lang.Exception
This method is called just before this script is executed for the first time.Override this method in your
VirtualUserScript
subclass if you have code which should be run only once, beforescript()
is executed.- Throws:
java.lang.Exception
- An error occurred
-
getIsStopped
protected boolean getIsStopped()
Internal use only.- Returns:
- Internal use only
-
stopImmediately
public void stopImmediately()
Internal use only.
-
getBackgroundScriptID
public java.lang.String getBackgroundScriptID()
Gets the script ID, which was provided when this script was started as a background script.- Returns:
- the script ID
-
setBackgroundScriptID
protected void setBackgroundScriptID(java.lang.String backgroundScriptID)
For internal use only.- Parameters:
backgroundScriptID
- Internal use only
-
setCancellationToken
public void setCancellationToken(CustomCancellationToken ct)
For internal use only.- Parameters:
ct
- Internal use only
-
tryToSuspend
protected void tryToSuspend()
Try to suspend a background script. It won't succeed if it is already locked by another script/VU.
-
onBackgroundScriptCancellation
protected void onBackgroundScriptCancellation()
Called when the background script executing in a loop is cancelled
-
acceptCancellation
public void acceptCancellation()
Called to accept the script response to the requested cancellation. It means this script would have ScriptStatus.Canceleld when afterwards. If this method is not called and the scipt is successefuly finished, then the status of the script is ScriptStatus.RanToCompletion
-
checkIfCancellationRequested
protected boolean checkIfCancellationRequested()
For internal use only.- Returns:
- Internal use only
-
suspend
public void suspend()
Asks the background script to suspend.
-
resume
public void resume()
Resumes the background script (which was previously suspended).
-
getBackgroundScriptIDs
public java.util.List<java.lang.String> getBackgroundScriptIDs()
Returns a list of currently registered wtih the VU background script IDs.- Returns:
- a list of currently registered wtih the VU background script IDs.
-
getBackgroundScriptStatus
public ScriptStatus getBackgroundScriptStatus(java.lang.String id)
Returns a status of the given background script.- Parameters:
id
- Unique script ID, identifying the background script.- Returns:
- the status of the specified background script
-
createBackgroundScript
public void createBackgroundScript(java.lang.String id, java.lang.String vuScriptClassName, AutomaticStopCriteria stopCriterion, java.util.EnumSet<ExecutionFlags> executionFlags, java.time.Duration pauseBetweenScriptsLoops, java.time.Duration autoStopTimeout) throws java.lang.Exception
Creates a new background script and starts it if requested.- Parameters:
id
- Unique script ID, identifying the background script.vuScriptClassName
- Fully qualified script's class name.stopCriterion
- Automatic stop criterion, describing how and when to terminate the background script (if at all).executionFlags
- Bitwise flags describing execution of the script.pauseBetweenScriptsLoops
- If script is run in a loop (executionFlags contain ExecutionFlags.Loop) then you can set the pause between such loops. Zero here means no pause.autoStopTimeout
- Automatic timeout is used when stopCriterion is not AutomaticStopCriteria.NeverStopAutomatically. If it is null, default setting from VU Group is used instead. Zero here means no wait. -1 ms timeout mean indefinite timeout.- Throws:
java.lang.Exception
- An error occurred
-
createBackgroundScript
public void createBackgroundScript(java.lang.String id, java.lang.String vuScriptClassName) throws java.lang.Exception
Creates a new background script and starts it.- Parameters:
id
- Unique script ID, identifying the background script.vuScriptClassName
- Fully qualified script's class name. This is an overload method, which is equivalent to createBackgroundScript(id, vuScriptClassName, AutomaticStopCriteria.StopImmediatelyAtEndOfVirtualUser, EnumSet.of(ExecutionFlags.LongRunningScript, ExecutionFlags.SingleShot), Duration.ZERO, null);- Throws:
java.lang.Exception
- An error occurred
-
startBackgroundScript
public void startBackgroundScript(java.lang.String id)
Starts previously created and not started background script- Parameters:
id
- Unique script ID, identifying the background script.
-
requestToStopBackgroundScript
public void requestToStopBackgroundScript(java.lang.String id) throws java.lang.InterruptedException
Requests currently running background script to stop. Since it just requests it to stop, the background script must check periodically if it was asked to do so and gracefully exit when detects it by checking this.ct.IsCancellationRequested flag.- Parameters:
id
- Unique script ID, identifying the background script.- Throws:
java.lang.InterruptedException
- if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
-
stopBackgroundScriptImmediately
public void stopBackgroundScriptImmediately(java.lang.String id) throws java.lang.InterruptedException
Tells the script to stop immediately. It will result in the script terminating if it calls any API or exits itself by checking this.ct.IsCancellationRequested flag. Mind that if it does something in a tight loop or made a call to another library it can take as much time as it needed to finish those operations.- Parameters:
id
- Unique script ID, identifying the background script.- Throws:
java.lang.InterruptedException
- if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
-
suspendBackgroundScript
public void suspendBackgroundScript(java.lang.String id) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
Suspends currently executing background script.- Parameters:
id
- Unique script ID, identifying the background script.- Throws:
java.lang.InterruptedException
- if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.java.util.concurrent.ExecutionException
- when attempting to retrieve the result of a task that aborted by throwing an exception
-
resumeBackgroundScript
public void resumeBackgroundScript(java.lang.String id) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
Resumes currently suspended background script.- Parameters:
id
- Unique script ID, identifying the background script.- Throws:
java.lang.InterruptedException
- if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.java.util.concurrent.ExecutionException
- when attempting to retrieve the result of a task that aborted by throwing an exception
-
waitForBackgroundScriptToFinish
public void waitForBackgroundScriptToFinish(java.lang.String id, java.time.Duration timeout) throws java.lang.InterruptedException
Waits for the background script to finish work in the given timeout, if timeout is not provided or null it waits until the tasks finish (if at all), if timeout is not null, then it returns false if it expired before the timeout reached.- Parameters:
id
- Unique script ID, identifying the background script.timeout
- How long to wait before give up- Throws:
java.lang.InterruptedException
- if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
-
getVirtualUser
public final VirtualUser getVirtualUser()
Gets the current VU instance, as an object of typeVirtualUser
.If you have added methods to a custom Virtual User subclass, they will not be callable on the object returned from this method. Instead use
getVU()
.- Returns:
- the current VU instance
- See Also:
getVU()
-
getVU
public VirtualUser getVU()
Gets the current VU instance, as the most specialised subclass ofVirtualUser
.If you have added methods to a custom Virtual User subclass, you can call them on the object returned from this method.
e.g.
MyCustomUser thisVU = getVU(); thisVU.MyCustomOperation();
- Returns:
- the current VU instance
-
getScriptName
public final java.lang.String getScriptName()
Gets the name of this Virtual User Script.e.g.
writeMessage(String.format("Script is: %s", getScriptName()));
- Returns:
- the name of this Virtual User Script
-
finishIterating
public final void finishIterating()
Prevents further iterations of the iterated sequence of scripts for this Virtual User.The current script will continue executing, and any subsequent scripts in the iterated sequence of scripts will also be executed. Once the end of the iteration is reached, the Virtual User will not start another iteration but will instead execute the scripts in the final sequence of scripts before exiting.
-
finishIteratingRequested
public boolean finishIteratingRequested()
Returnstrue
if this Virtual User has been requested to finish iterating. This happens whenfinishIterating()
is called.- Returns:
true
if this Virtual User has been requested to finish iterating
-
getLastError
public java.lang.String getLastError()
Gets the most recent error encountered by this Virtual User.- Returns:
- the most recent error encountered by this Virtual User
-
isInitialScript
public final boolean isInitialScript()
Returnstrue
if the current executing script is within the initial section of this Virtual User's workflow.- Returns:
true
if the current executing script is within the initial section of this Virtual User's workflow- See Also:
isFinalScript()
,isIteratedScript()
-
isIteratedScript
public final boolean isIteratedScript()
Returnstrue
if the current executing script is within the repeated section of this Virtual User's workflow.- Returns:
true
if the current executing script is within the repeated section of this Virtual User's workflow- See Also:
isInitialScript()
,isFinalScript()
-
isFirstScript
public boolean isFirstScript()
Returnstrue
if the current executing script is the first script to be executed.- Returns:
- Returns
true
if the current executing script is the first script to be executed.
-
getIterationForTime
public int getIterationForTime()
Gets the time in milliseconds that the iterated sequence of scripts will iterate for.- Returns 0 if the iterated sequence of scripts have been set to execute a certain number of iterations, or to iterate forever.
- Returns a value greater than 0 if the iterated sequence of scripts have been set to execute for a given length of time.
- Returns:
- the time in milliseconds that the iterated sequence of scripts will iterate for
-
isFinalScript
public final boolean isFinalScript()
Returnstrue
if the current executing script is within the final section of this Virtual User's workflow.- Returns:
true
if the current executing script is within the final section of this Virtual User's workflow- See Also:
isInitialScript()
,isIteratedScript()
-
getNumberOfFailures
public final int getNumberOfFailures()
Gets the current number of script failures for this Virtual User.Failures are exceptions - such as communication exceptions - which are caught and produce an error message in the event log. They do not cause the Virtual User to exit until the number of failures reaches the value returned by
getMaxFailures()
.- Returns:
- the current number of script failures for this Virtual User
- See Also:
getMaxFailures()
-
getMaxFailures
public final int getMaxFailures()
Gets the maximum number of failures allowed in the script before this Virtual User terminates.Failures are exceptions - such as communication exceptions - which are caught and produce an error message in the event log. They do not cause the Virtual User to exit until the number of failures reaches this value.
- Returns:
- the maximum number of failures allowed in the script before this Virtual User terminates
- See Also:
getNumberOfFailures()
-
flushEventLog
public final void flushEventLog() throws java.lang.Exception
Flushes the event log to disk.Any events still held in-memory are written to the Virtual User event log on disk. This enables the event log file to be viewed before the test has completed.
Note that writing an error event also flushes the log.
- Throws:
java.lang.Exception
- An error occurred- See Also:
warn(String)
,writeMessage(String)
,error(String)
-
getDataTable
public final DataTable getDataTable(java.lang.String key) throws NoSuchValueException
Gets the specified Data Table.This method allows you to locate the existing Data Table by name. The dictionaries it contains can then be accessed by using the appropriate methods of
DataTable
.- Parameters:
key
- the name of theDataTable
- Returns:
- a reference to a named
DataTable
object - Throws:
NoSuchValueException
- the data table does not exist
-
isPacing
public final boolean isPacing()
Returnstrue
if this Virtual User will adjust the delay between iterations to maintain a steady pace of iterations.The Virtual User pauses between each iteration of the iterated sequence of scripts. If the pacing option is selected in the VU Group runtime properties in eggPlant Performance Studio, then the iteration delay value is adjusted each time to maintain a fixed rate of script iterations.
- Returns:
true
if this Virtual User will adjust the delay between iterations to maintain a steady pace of iterations- See Also:
getIterationDelay()
-
lastIterationDelay
public final int lastIterationDelay()
Gets the delay time in milliseconds between the previous iteration and the current iteration.This method will return zero on the first iteration. If the pacing option is selected, then the iteration delay value is adjusted each time to maintain a fixed rate of script iterations.
- Returns:
- the time between the previous iteration and the current iteration, in milliseconds
- See Also:
getIterationDelay()
,isPacing()
-
getNumberOfIterations
public final int getNumberOfIterations()
Gets the total number of iterations that the repeated sequence of scripts will execute.A return value of zero indicates that the iterated scripts are iterating for a specified time or forever, and not for a specified number of iterations.
- Returns:
- the number of iterations that the repeated sequence of scripts will execute, as set in the VU Group runtime settings in eggPlant Performance Studio
-
getNumberOfWarmupIterations
public final int getNumberOfWarmupIterations()
Gets the number of warm-up iterations for this Virtual User.The value indicates the number of warm-up iterations this Virtual User will execute and is only relevant to the repeated sequence of scripts. Warm-up iterations are considered to be of no interest statistically and during a warm-up iteration the start and end transaction events are not written to the event log of the VU.
- Returns:
- the number of warm-up iterations for this Virtual User
- See Also:
startTransaction(String)
,endTransaction(String)
-
setNumberOfWarmupIterations
public final void setNumberOfWarmupIterations(int numberOfWarmupIterations)
Sets the number of warm-up iterations for this Virtual User.The value indicates the number of warm-up iterations this Virtual User will execute and is only relevant to the repeated sequence of scripts. Warm-up iterations are considered to be of no interest statistically and during a warm-up iteration the start and end transaction events are not written to the event log of the VU.
- Parameters:
numberOfWarmupIterations
- the number of warm-up iterations for this Virtual User- See Also:
startTransaction(String)
,endTransaction(String)
-
getIteration
public final int getIteration()
Gets the number of the iteration that this Virtual User is currently executing (beginning at 0).As a Virtual User completes execution of the iterated sequence of scripts, the iteration number is increased by 1 and execution of the next iteration of the iterated sequence of scripts is started from the beginning.
This method returns 0 if this Virtual User is executing the first iteration. Compare to
getCurrentIteration()
.- Returns:
- the number of the iteration that this Virtual User is currently executing (beginning at 0)
-
getCurrentIteration
public final int getCurrentIteration()
Gets the number of the iteration that this Virtual User is currently executing (beginning at 1).As a Virtual User completes execution of the iterated sequence of scripts, the iteration number is increased by 1 and execution of the next iteration of the iterated sequence of scripts is started from the beginning.
This method returns 1 if this Virtual User is executing the first iteration. Compare to
getIteration()
.- Returns:
- the number of the iteration that this Virtual User is currently executing (beginning at 1)
-
getDataDictionary
public final DataDictionary getDataDictionary()
Gets the Data Dictionary belonging to thisVirtualUser
.- Returns:
- the Data Dictionary belonging to this
VirtualUser
-
getDataDictionary
public final DataDictionary getDataDictionary(java.lang.String key) throws NoSuchValueException
Gets the Data Dictionary named with the specifiedkey
and assigned to the Virtual User in eggPlant Performance Studio.- Parameters:
key
- the name of the Data Dictionary as it appears in eggPlant Performance Studio- Returns:
- the specified Data Dictionary
- Throws:
NoSuchValueException
- the dictionary does not exist
-
getElapsedTime
public final int getElapsedTime()
Gets the elapsed time since the beginning of the test, in milliseconds.- Returns:
- the elapsed time since the beginning of the test, in milliseconds
-
getInitialDelay
public final int getInitialDelay()
Gets the initial delay for this Virtual User, between the start of the test and the start of the first script execution.By the time this method can be called, the initial delay will already have happened, and this will return the actual number of milliseconds that this Virtual User waited before starting script execution. The value returned includes the initial group delay and the ramp-up for this specific Virtual User.
- Returns:
- the initial delay, in milliseconds
-
getIterationDelay
public final int getIterationDelay()
Gets the delay time in milliseconds between iterations of the repeated sequence of scripts.This is the value set in the VU Group runtime properties in eggPlant Performance Studio. If the pacing option is selected, then the iteration delay value is adjusted each time to maintain a fixed rate of script iterations.
- Returns:
- the time between iterations, in milliseconds
- See Also:
lastIterationDelay()
-
writeSystemLog
public final void writeSystemLog(java.lang.String message)
Writes an alert of Error severity to the Alerts table in Test Controller.This method was included for backwards compatibility with older eggPlant Performance scripts. The Test Controller Alerts table is made accessible from the script using
writeSystemLog(String)
.writeSystemLog()
will add an alert of severity level Error. Other table fields include the time into the test the error alert was raised (HH:MM:SS), the source of the alert (this will always be 'Engine' when called from the script), the index of the VU which raised the alert and the injector that the VU was deployed on, the group which the VU was a member of and the script that the VU was executing when the alert was raised.WriteSystemLog must be used sparingly. It is possible to flood the Alerts log. For diagnostic purposes use
writeMessage(String)
,setProgressPoint(String)
,error(String)
andwarn(String)
to output to the VU event log; this can be viewed at runtime in Test Controller. The Alerts log should only be used for a small number of important messages.- Parameters:
message
- an alert message which appears in the Description column of the alerts table in the Alerts sub-view of Test Controller- See Also:
raiseAlert(int, String)
,writeMessage(String)
,error(String)
,warn(String)
-
writeSystemLog
public final void writeSystemLog(java.lang.String heading, java.lang.String message)
Writes an alert of Error severity to the Alerts table in Test Controller, specifying aheading
to prefix to themessage
.This method was included for backwards compatibility with older eggPlant Performance scripts. The Test Controller Alerts table is made accessible from the script using
writeSystemLog(String)
.writeSystemLog()
will add an alert of severity level Error. Other table fields include the time into the test the error alert was raised (HH:MM:SS), the source of the alert (this will always be 'Engine' when called from the script), the index of the VU which raised the alert and the injector that the VU was deployed on, the group which the VU was a member of and the script that the VU was executing when the alert was raised.WriteSystemLog must be used sparingly. It is possible to flood the Alerts log. For diagnostic purposes use
writeMessage(String)
,setProgressPoint(String)
,error(String)
andwarn(String)
to output to the VU event log; this can be viewed at runtime in Test Controller. The Alerts log should only be used for a small number of important messages.- Parameters:
heading
- aString
to be prefixed to the outputmessage
message
- an alert message which appears in the Description column of the alerts table in the Alerts sub-view of Test Controller- See Also:
raiseAlert(int, String)
,writeMessage(String)
,error(String)
,warn(String)
-
raiseAlert
public final void raiseAlert(int severity, java.lang.String message)
Writes an alert of the specifiedseverity
to the Alerts table in Test Controller.The
AlertManager
class contains static final variables which can be passed as theseverity
parameter, i.e.AlertManager.Information
,AlertManager.Warning
andAlertManager.Error
.RaiseAlert must be used sparingly. It is possible to flood the Alerts log. For diagnostic purposes use
writeMessage(String)
,setProgressPoint(String)
,error(String)
andwarn(String)
to output to the VU event log; this can be viewed at runtime in Test Controller. The Alerts log should only be used for a small number of important messages.- Parameters:
severity
- the severity of the alertmessage
- an alert message which appears in the Description column of the alerts table in the Alerts sub-view of Test Controller
-
warn
public final void warn(java.lang.String id, java.lang.String info)
Writes a warning message to the VU event log, specifying an identifier which appears in the ID column.- Parameters:
id
- the warning identifier, which appears in the ID columninfo
- a warning message which appears in the Info column
-
warn
public void warn(java.lang.String id, java.lang.String info, java.lang.String imagePath) throws java.io.FileNotFoundException
Writes a warning message and an image link to the VU event log, specifying an identifier which appears in the ID column.An error message is written to the VU event log, and then the event log is flushed.
The image must be contained within the run directory (as returned by
getRunPath()
, and the path passed should be relative to this path.- Parameters:
id
- the error identifier, which appears in the ID columninfo
- an error message which appears in the Info columnimagePath
- the path to an image file (such as a png or bmp). The path should be a relative path.- Throws:
java.io.FileNotFoundException
- The image specified does not exist
-
warn
public final void warn(java.lang.Exception e)
Writes a warning message to the VU event log, consisting of the specified exception- Parameters:
e
- The exception to write to the event log.
-
warn
public final void warn(java.lang.String info)
Writes a warning message to the VU event log.- Parameters:
info
- a warning message which appears in the Info column
-
error
public final void error(java.lang.String id, java.lang.String info)
Writes an error message to the VU event log, specifying an identifier which appears in the ID column.An error message is written to the VU event log, and then the event log is flushed.
- Parameters:
id
- the error identifier, which appears in the ID columninfo
- an error message which appears in the Info column
-
error
public void error(java.lang.String message, java.lang.Exception e)
Writes an error message to the VU event log, which will include the stack trace of the specifiedException
.An error event is written to the VU's event log and the the event log is flushed.
- Parameters:
message
- an error message which appears in the Info columne
- the stack trace of thisException
will be recorded in the error message
-
error
public void error(java.lang.Exception e)
Writes an error message to the VU event log, which will consist of the details of the specified Exception.An error message is written to the VU event log, and then the event log is flushed.
- Parameters:
e
- The exception to record in the event log.
-
error
public void error(java.lang.String id, java.lang.String info, java.lang.String imagePath) throws java.io.FileNotFoundException
Writes an error message and an image link to the VU event log, specifying an identifier which appears in the ID column.An error message is written to the VU event log, and then the event log is flushed.
The image must be contained within the run directory (as returned by
getRunPath()
, and the path passed should be relative to this path.- Parameters:
id
- the error identifier, which appears in the ID columninfo
- an error message which appears in the Info columnimagePath
- the path to an image file (such as a png or bmp). The path should be a relative path.- Throws:
java.io.FileNotFoundException
- The image specified does not exist
-
error
public final void error(java.lang.String info)
Writes an error message to the VU event log.An error message is written to the VU event log, and then the event log is flushed.
- Parameters:
info
- an error message which appears in the Info column
-
getNumberOfWarnings
public int getNumberOfWarnings()
Gets the number of warnings that have been reported for this Virtual User.- Returns:
- the number of warnings that have been reported for this Virtual User
-
getNumberOfErrors
public int getNumberOfErrors()
Gets the number of errors that have been reported for this Virtual User.- Returns:
- the number of errors that have been reported for this Virtual User
-
pause
public int pause(int interval) throws BadValueException, ContextTerminationException
Pauses the execution of the script for a specifiedinterval
(modified bygetPauseFactor()
).The specified
interval
may be altered by a previous call tosetPauseFactor(int)
or by the runtime options set in eggPlant Performance Studio.- Parameters:
interval
- the number of milliseconds to pause before executing the next statement- Returns:
- the length of time that the script actually paused for, in milliseconds
- Throws:
BadValueException
- the interval is less than 0ContextTerminationException
- This Virtual User has been terminated
-
pause
public int pause() throws BadValueException, ContextTerminationException
Pauses the execution of the script.The script pauses for a random number of milliseconds between the minimum and maximum values set in eggPlant Performance Studio. The actual pause time may be altered by a previous call to
setPauseFactor(int)
or by the runtime options set in eggPlant Performance Studio.- Returns:
- the length of time that the script paused for, in milliseconds
- Throws:
BadValueException
- Invalid pause interval settingsContextTerminationException
- This Virtual User has been terminated
-
timeToPause
public int timeToPause(int interval) throws BadValueException
Gets the length of time that this Virtual User would pause for ifpause(int)
were called with the specifiedinterval
.When calling
pause(int)
, a length of time in milliseconds is passed as a parameter. The actual pause time may be different, depending on values passed tosetPauseFactor(int)
or runtime options set in eggPlant Performance Studio. This method returns the actual time that the Virtual User would pause for, ifpause(int)
were called with the specifiedinterval
.- Parameters:
interval
- the interval, in milliseconds- Returns:
- the actual length of the pause, in milliseconds
- Throws:
BadValueException
- the interval is less than 0
-
getIndex
public final int getIndex()
Gets the index number of this Virtual User within the Virtual User group that it belongs to.The first Virtual User has index 1.
e.g.
// pause for 1 second, every 10th VU if ((getIndex() % 10) == 0) { pause(1000); }
- Returns:
- the index number of this Virtual User within the Virtual User group that it belongs to
-
getPauseFactor
public final int getPauseFactor()
Gets the current percentage pause factor.The length of time which this Virtual User will pause for when the
pause()
orpause(int)
methods are called will be multiplied by the percentage pause factor.e.g. a percentage pause factor of 200 will make pauses last twice as long, and a percentage pause factor of 50 will make pauses last half as long.
- Returns:
- a percentage factor to apply to all subsequent
pause()
statements
-
setPauseFactor
public final void setPauseFactor(int pauseFactor) throws BadValueException
Sets the current percentage pause factor.You can use this property to slow down or speed up a running test, by changing the length of time that this Virtual User will pause for.
e.g.
// to make all pauses twice as long (200%) setPauseFactor(200); // or to reduce all following pauses to 10% of their stated value setPauseFactor(10);
- Parameters:
pauseFactor
- a percentage factor to apply to all subsequentpause()
statements- Throws:
BadValueException
- Invalid pause factor- See Also:
pause()
-
clearProgressPoint
public final void clearProgressPoint()
Clears the current progress point set for this Virtual User.This has the effect of clearing the Progress Point column in Test Controller for this Virtual User.
-
setProgressPoint
public final void setProgressPoint(java.lang.String progressPoint) throws java.lang.Exception
Sets a progress point in the VU event log.A progress point can be used to indicate that the execution of a script has reached a certain point, or that the application under test is in a certain state. The
progressPoint
text will be written to the VU event log, and will appear in Test Controller summary views during the test.e.g.
setProgressPoint("AtLogon");
- Parameters:
progressPoint
- the progress point identifier, which will appear in the Progress Point column in Test Controller- Throws:
java.lang.Exception
- An error occurred
-
setProgressPoint
public final void setProgressPoint(java.lang.String progressPoint, boolean pass) throws java.lang.Exception
Sets a progress point in the VU event log, specifying whether the progress point passed.A progress point can be used to indicate that the execution of a script has reached a certain point, or that the application under test is in a certain state. The
progressPoint
text, and whether it passed or failed will be written to the VU event log, and will appear in Test Controller summary views during the test.e.g.
setProgressPoint("AtLogon"); String response = .... // the response from the server if (response.contains("Invalid User or Password")) { setProgressPoint("logon", false); // logon failed } else { setProgressPoint("logon", true); // logon OK }
- Parameters:
progressPoint
- the progress point identifier, which will appear in the Progress Point column in Test Controllerpass
-true
if the progress point should be interpreted as a pass- Throws:
java.lang.Exception
- An error occurred
-
setProgressPoint
public final void setProgressPoint(java.lang.String progressPoint, java.lang.String info, boolean pass) throws java.lang.Exception
Sets a progress point in the VU event log, specifying whether the progress point passed and specifying extra information which appears in the Info column.A progress point can be used to indicate that the execution of a script has reached a certain point, or that the application under test is in a certain state. The
progressPoint
text, and whether it passed or failed will be written to the VU event log, and will appear in Test Controller summary views during the test.e.g.
setProgressPoint("AtLogon"); String response = .... // the response from the server if (response.contains("Invalid User or Password")) { setProgressPoint("logon", response, false); // logon failed } else { setProgressPoint("logon", response, true); // logon OK }
- Parameters:
progressPoint
- the progress point identifier, which will appear in the Progress Point column in Test Controllerinfo
- extra information which appears in the Info columnpass
-true
if the progress point should be interpreted as a pass- Throws:
java.lang.Exception
- An error occurred
-
getProgressPoint
public java.lang.String getProgressPoint()
Gets the text of the most recent progress point that was set.- Returns:
- the text of the most recent progress point that was set
-
exitVU
public final void exitVU() throws ContextTerminationException
Stops execution of this Virtual User.The script processing for this Virtual User is immediately ended (i.e. all further statements in this script are not executed, and the execution of all further scripts is also stopped). An information message is written to the VU event log to indicate that
exitVU()
has been called, and the final end entry in the log is written.This method raises a
ContextTerminationException
and under normal conditions you should not write any code to catch this exception, as this would interfere with the mechanism of the eggPlant Performance engine.- Throws:
ContextTerminationException
- This Virtual User has been terminated
-
exitVU
public final void exitVU(boolean pass) throws ContextTerminationException
Stops execution of this Virtual User, specifying whether the script completed successfully.The script processing for this Virtual User is immediately ended (i.e. all further statements in this script are not executed, and the execution of all further scripts is also stopped). An information message is written to the VU event log to indicate that
exitVU()
has been called, and the final end entry in the log is annotated with Pass or Fail in the ID column depending on the value ofpass
. The Virtual User will also be counted in the In Error column in Test Controller ifpass
isfalse
.This method raises a
ContextTerminationException
and under normal conditions you should not write any code to catch this exception, as this would interfere with the mechanism of the eggPlant Performance engine.- Parameters:
pass
-true
if the script should be considered to have completed successfully- Throws:
ContextTerminationException
- This Virtual User has been terminated
-
exitVU
public final void exitVU(java.lang.String msg, boolean pass) throws ContextTerminationException
Stops execution of this Virtual User, specifying whether the script completed successfully and a message to display at the end of the event log.The script processing for this Virtual User is immediately ended (i.e. all further statements in this script are not executed, and the execution of all further scripts is also stopped). An information message is written to the VU event log to indicate that
exitVU()
has been called, and the final end entry in the log is annotated with Pass or Fail in the ID column depending on the value ofpass
. The Virtual User will also be counted in the In Error column in Test Controller ifpass
isfalse
.This method raises a
ContextTerminationException
and under normal conditions you should not write any code to catch this exception, as this would interfere with the mechanism of the eggPlant Performance engine.- Parameters:
msg
- an information message which appears in the Info column of the end entrypass
-true
if the script should be considered to have completed successfully- Throws:
ContextTerminationException
- This Virtual User has been terminated
-
getCurrentTransaction
public java.lang.String getCurrentTransaction()
Gets the name of the transaction that is currently in progress.This is the name of the most recent transaction to be started by a call to
startTransaction(String)
. If no transaction is currently in progress, then an emptyString
will be returned.- Returns:
- the name of the transaction that is currently in progress
-
nextIteration
public final void nextIteration() throws ScriptContextTerminationException
Stops execution of the current script, and starts execution of the next iteration.The execution of the calling script ceases and the execution of the next iteration of scripts is begun. If the sequence of scripts being executed is the initial or final sequence of scripts, then the execution of this sequence is curtailed. Otherwise, the execution of the repeated sequence of scripts begins again at the next iteration.
This method raises a
ScriptContextTerminationException
, and under normal conditions you should not write any code to catch this exception, as this would interfere with the mechanism of the eggPlant Performance engine.- Throws:
ScriptContextTerminationException
- This script has been terminated
-
finalSequence
public final void finalSequence() throws ScriptContextTerminationException
Stops execution of the current script and then executes the scripts in the final section of the current workflow.The execution of the calling script ceases and the execution of all further scripts in the current sequence is curtailed.
This method raises a
ScriptContextTerminationException
, and under normal conditions you should not write any code to catch this exception, as this would interfere with the mechanism of the eggPlant Performance engine.- Throws:
ScriptContextTerminationException
- This script has been terminated
-
nextSequence
public final void nextSequence() throws ScriptContextTerminationException
Stops execution of the current script and any other scripts in the current sequence, and starts execution of the next sequence of scripts.This method raises a
ScriptContextTerminationException
, and under normal conditions you should not write any code to catch this exception, as this would interfere with the mechanism of the eggPlant Performance engine.- Throws:
ScriptContextTerminationException
- This script has been terminated
-
nextScript
public final void nextScript() throws ScriptContextTerminationException
Stops execution of the current script, and starts execution of the next script in the sequence.The execution of the calling script ceases and the execution of the next script in the sequence of scripts to be executed is begun. This method and the return statement are not equivalent. This method should be used in preference to the return statement. Remember that a
VirtualUserScript
may have additional methods other thanscript()
and executing a return statement from anywhere other than thescript()
method will not exit the execution of theVirtualUserScript
object.This method raises a
ScriptContextTerminationException
and under normal conditions you should not write any code to catch this exception, as this would interfere with the mechanism of the eggPlant Performance engine.- Throws:
ScriptContextTerminationException
- This script has been terminated
-
startTiming
public void startTiming(java.lang.String id) throws java.lang.Exception
Writes a start timing event to the VU event log.The time in milliseconds since the start of the test run is recorded when this method is called. When
endTiming(String)
is called with the sameid
, an end timing event is written to the VU event log. eggPlant Performance uses the time difference between the events to calculate the timing with the specifiedid
.Timings are similar to transactions but are measured and grouped separately in test results.
- Parameters:
id
- the timing identifier- Throws:
java.lang.Exception
- An error occurred- See Also:
endTiming(String)
,endTiming(String, boolean)
-
startTransaction
public void startTransaction(java.lang.String id) throws java.lang.Exception
Writes a start transaction event to the VU event log.The time in milliseconds since the start of the test run is recorded when this method is called. When
endTransaction(String)
is called with the sameid
, an end transaction event is written to the VU event log. eggPlant Performance uses the time difference between the events to calculate the transaction time for the transaction named with the specifiedid
.Test Controller and Analyzer use the transaction times to calculate statistics such as average transaction time for each different
id
. These statistics give an indication of the performance of the System Under Test, as they show how long it takes for Virtual Users to perform the actions.- Parameters:
id
- the transaction identifier- Throws:
java.lang.Exception
- An error occurred- See Also:
endTransaction(String)
,suspendTransaction(String)
,resumeTransaction(String)
-
startTransaction
public void startTransaction(java.lang.String id, java.lang.String tag) throws java.lang.Exception
Writes a start transaction event to the VU event log, specifying atag
which appears in the Info column.The time in milliseconds since the start of the test run is recorded when this method is called. When
endTransaction(String)
is called with the sameid
, an end transaction event is written to the VU event log. eggPlant Performance uses the time difference between the events to calculate the transaction time for the transaction named with the specifiedid
.Test Controller and Analyzer use the transaction times to calculate statistics such as average transaction time for each different
id
. These statistics give an indication of the performance of the System Under Test, as they show how long it takes for Virtual Users to perform the actions.- Parameters:
id
- the transaction identifiertag
- extra information which appears in the Info column- Throws:
java.lang.Exception
- An error occurred- See Also:
endTransaction(String, boolean, String)
,suspendTransaction(String)
,resumeTransaction(String)
-
getTransactionElapsedTime
public int getTransactionElapsedTime(java.lang.String id) throws ContextTerminationException
Gets the current elapsed time of the transaction with the specifiedid
.e.g.
startTransaction("Transaction1"); // do activity if (getTransactionElapsedTime("Transaction1") > 5000) { setProgressPoint("Activity > 5 Seconds"); } // do more activity endTransaction("Transaction1", true);
- Parameters:
id
- the transaction identifier- Returns:
- the elapsed time of the transaction, in milliseconds
- Throws:
ContextTerminationException
- This Virtual User has been terminated
-
getTransactionElapsedTime
public int getTransactionElapsedTime(java.lang.String id, java.lang.String tag) throws ContextTerminationException
Gets the current elapsed time of the transaction with the specifiedid
andtag
.e.g.
startTransaction("Transaction1", "Tag1"); // do activity startTransaction("Transaction1", "Tag2"); if (getTransactionElapsedTime("Transaction1", "Tag1") > 5000) { setProgressPoint("Activity > 5 Seconds"); } endTransaction("Transaction1", true, "Tag1"); // do more activity endTransaction("Transaction1", true, "Tag2");
- Parameters:
id
- the identifier of the transactiontag
- the transaction tag- Returns:
- the elapsed time of the transaction, in milliseconds
- Throws:
ContextTerminationException
- This Virtual User has been terminated
-
getTimingElapsedTime
public int getTimingElapsedTime() throws ContextTerminationException
Gets the elapsed time of the current active timing.Returns 0 (zero) if there is no current timing. A timing can be started using the
startTiming(String)
method.e.g.
startTiming("Timing1"); // do activity if (getTimingElapsedTime() > 5000) { setProgressPoint("Activity > 5 Seconds"); } // do more activity endTiming("Timing1");
- Returns:
- the elapsed time of the timing, in milliseconds
- Throws:
ContextTerminationException
- This Virtual User has been terminated
-
isLastIteration
public final boolean isLastIteration()
Returnstrue
if more iterations will occur for the current Virtual User.If the currently executing script belongs to the initial or final sequence of scripts in this Virtual User's workflow, then this will always return
true
.If the currently executing script belongs to the iterated sequence of scripts and this method returns
true
, then the VU will cease to iterate once the current sequence has completed execution.If the Virtual User is set to iterate for a certain length of time, then the time remaining is checked and an estimate is made as to whether further iterations may occur.
- Returns:
true
if there will be no more iterations in the current sequence
-
suspendTransaction
public final void suspendTransaction(java.lang.String id, java.lang.String tag) throws java.lang.Exception
Suspends the timing of the specified transaction, identified bytag
as well asid
.Use
resumeTransaction(String, String)
to resume timing again afterwards.e.g.
startTransaction("login", "1"); // This should be included in the transaction time goToLoginPage(); suspendTransaction("login", "1"); // The time taken for this processing to be done will be // subtracted from the total "login" transaction time // because it isn't related to the performance of the SUT prepareLoginDetails(); resumeTransaction("login", "1"); // This should be included in the transaction time performLogin(); endTransaction("login", true, "1");
- Parameters:
id
- the transaction identifiertag
- the transaction tag- Throws:
java.lang.Exception
- An error occurred- See Also:
resumeTransaction(String,String)
,startTransaction(String, String)
,endTransaction(String, boolean, String)
-
suspendTransaction
public final void suspendTransaction(java.lang.String id) throws java.lang.Exception
Suspends the timing of the specified transaction.Use
resumeTransaction(String)
to resume timing again afterwards.e.g.
startTransaction("login"); // This should be included in the transaction time goToLoginPage(); suspendTransaction("login"); // The time taken for this processing to be done will be // subtracted from the total "login" transaction time // because it isn't related to the performance of the SUT prepareLoginDetails(); resumeTransaction("login"); // This should be included in the transaction time performLogin(); endTransaction("login");
- Parameters:
id
- the transaction identifier- Throws:
java.lang.Exception
- An error occurred- See Also:
resumeTransaction(String)
,startTransaction(String)
,endTransaction(String)
-
resumeTransaction
public final void resumeTransaction(java.lang.String id, java.lang.String tag) throws java.lang.Exception
Resumes the timing of the specified transaction, identified bytag
as well asid
.Use this method after a call to
suspendTransaction(String, String)
.e.g.
startTransaction("login", "1"); // This should be included in the transaction time goToLoginPage(); suspendTransaction("login", "1"); // The time taken for this processing to be done will be // subtracted from the total "login" transaction time // because it isn't related to the performance of the SUT prepareLoginDetails(); resumeTransaction("login", "1"); // This should be included in the transaction time performLogin(); endTransaction("login", true, "1");
- Parameters:
id
- the transaction identifiertag
- the transaction tag- Throws:
java.lang.Exception
- An error occurred- See Also:
suspendTransaction(String,String)
,startTransaction(String, String)
,endTransaction(String, boolean, String)
-
resumeTransaction
public final void resumeTransaction(java.lang.String id) throws java.lang.Exception
Resumes the timing of the specified transaction.Use this method after a call to
suspendTransaction(String)
.e.g.
startTransaction("login"); // This should be included in the transaction time goToLoginPage(); suspendTransaction("login"); // The time taken for this processing to be done will be // subtracted from the total "login" transaction time // because it isn't related to the performance of the SUT prepareLoginDetails(); resumeTransaction("login"); // This should be included in the transaction time performLogin(); endTransaction("login");
- Parameters:
id
- the transaction identifier- Throws:
java.lang.Exception
- An error occurred- See Also:
suspendTransaction(String)
,startTransaction(String)
,endTransaction(String)
-
getLastTransaction
public java.lang.String getLastTransaction()
Gets the name of the most recent transaction to have ended.- Returns:
- the name of the most recent transaction to have ended
-
endTransaction
public int endTransaction(java.lang.String id) throws java.lang.Exception
Writes an end transaction event to the VU event log.The time in milliseconds since the start of the test run is recorded when this method is called. The
startTransaction(String)
method should already have been called with the sameid
. eggPlant Performance uses the time difference between the events to calculate the transaction time for the transaction named with the specifiedid
.Test Controller and Analyzer use the transaction times to calculate statistics such as average transaction time for each different
id
. These statistics give an indication of the performance of the System Under Test, as they show how long it takes for Virtual Users to perform the actions.- Parameters:
id
- the transaction identifier- Returns:
- elapsed time in milliseconds since the start of the test
- Throws:
java.lang.Exception
- An error occurred- See Also:
startTransaction(String)
,suspendTransaction(String)
,resumeTransaction(String)
-
endTransaction
public int endTransaction(java.lang.String id, boolean pass) throws java.lang.Exception
Writes an end transaction event to the VU event log, specifying whether the transaction passed.The time in milliseconds since the start of the test run is recorded when this method is called. The
startTransaction(String)
method should already have been called with the sameid
. eggPlant Performance uses the time difference between the events to calculate the transaction time for the transaction named with the specifiedid
.Test Controller and Analyzer use the transaction times to calculate statistics such as average transaction time for each different
id
. These statistics give an indication of the performance of the System Under Test, as they show how long it takes for Virtual Users to perform the actions.If the transaction failed, then it will be counted separately in Test Controller and Analyzer.
- Parameters:
id
- the transaction identifierpass
-true
if the transaction should be interpreted as a pass- Returns:
- elapsed time in milliseconds since the start of the test
- Throws:
java.lang.Exception
- An error occurred- See Also:
startTransaction(String)
,suspendTransaction(String)
,resumeTransaction(String)
-
endTransaction
public int endTransaction(java.lang.String id, boolean pass, java.lang.String tag) throws java.lang.Exception
Writes an end transaction event to the VU event log, specifying whether the transaction passed, and specifying atag
which appears in the Info column.The time in milliseconds since the start of the test run is recorded when this method is called. The
startTransaction(String)
method should already have been called with the sameid
. eggPlant Performance uses the time difference between the events to calculate the transaction time for the transaction named with the specifiedid
.Test Controller and Analyzer use the transaction times to calculate statistics such as average transaction time for each different
id
. These statistics give an indication of the performance of the System Under Test, as they show how long it takes for Virtual Users to perform the actions.If the transaction failed, then it will be counted separately in Test Controller and Analyzer.
- Parameters:
id
- the transaction identifierpass
-true
if the transaction should be interpreted as a passtag
- extra information which appears in the Info column- Returns:
- elapsed time in milliseconds since the start of the test
- Throws:
java.lang.Exception
- An error occurred- See Also:
startTransaction(String, String)
,suspendTransaction(String)
,resumeTransaction(String)
-
failTransaction
public int failTransaction(java.lang.String id) throws java.lang.Exception
Writes a fail transaction event to the VU event log.The time in milliseconds since the start of the test run is recorded when this method is called. The
startTransaction(String)
method should already have been called with the sameid
. eggPlant Performance uses the time difference between the events to calculate the transaction time for the transaction named with the specifiedid
.This transaction will be interpreted as having failed, so it will be counted separately in Test Controller and Analyzer. This is equivalent to calling
endTransaction(String, boolean)
with a pass value offalse
.Test Controller and Analyzer use the transaction times to calculate statistics such as average transaction time for each different
id
. These statistics give an indication of the performance of the System Under Test, as they show how long it takes for Virtual Users to perform the actions.- Parameters:
id
- the transaction identifier- Returns:
- elapsed time in milliseconds since the start of the test
- Throws:
java.lang.Exception
- An error occurred- See Also:
startTransaction(String)
,endTransaction(String)
-
failTransaction
public int failTransaction(java.lang.String id, java.lang.String tag) throws java.lang.Exception
Writes a fail transaction event to the VU event log, specifying atag
which appears in the Info column.The time in milliseconds since the start of the test run is recorded when this method is called. The
startTransaction(String, String)
method should already have been called with the sameid
. eggPlant Performance uses the time difference between the events to calculate the transaction time for the transaction named with the specifiedid
.This transaction will be interpreted as having failed, so it will be counted separately in Test Controller and Analyzer. This is equivalent to calling
endTransaction(String, boolean, String)
with a pass value offalse
.Test Controller and Analyzer use the transaction times to calculate statistics such as average transaction time for each different
id
. These statistics give an indication of the performance of the System Under Test, as they show how long it takes for Virtual Users to perform the actions.- Parameters:
id
- the transaction identifiertag
- extra information which appears in the Info column- Returns:
- elapsed time in milliseconds since the start of the test
- Throws:
java.lang.Exception
- An error occurred- See Also:
startTransaction(String, String)
,endTransaction(String, boolean, String)
-
getTransactionLoggingOn
public final boolean getTransactionLoggingOn()
Returnstrue
if transactions should be logged for this VU.When the Transaction Logging flag is
false
, start and end transaction events are not written to the event log.- Returns:
true
if transactions should be logged- See Also:
setTransactionLoggingOn(boolean)
-
setTransactionLoggingOn
public final void setTransactionLoggingOn(boolean value)
Sets whether transactions should be logged for this VU.When the Transaction Logging flag is
false
, start and end transaction events are not written to the event log.- Parameters:
value
-true
if transactions should be logged- See Also:
getTransactionLoggingOn()
-
endTiming
public void endTiming(java.lang.String id) throws java.lang.Exception
Writes an end timing event to the VU event log.The time in milliseconds since the start of the test run is recorded when this method is called. The
startTiming(String)
method should already have been called with the sameid
. eggPlant Performance uses the time difference between the events to calculate the timing with the specifiedid
.Timings are similar to transactions but are measured and grouped separately in test results.
- Parameters:
id
- the timing identifier- Throws:
java.lang.Exception
- An error occurred- See Also:
startTiming(String)
-
endTiming
public void endTiming(java.lang.String id, boolean pass) throws java.lang.Exception
Writes an end timing event to the VU event log, specifying whether the timing passed.The time in milliseconds since the start of the test run is recorded when this method is called. The
startTiming(String)
method should already have been called with the sameid
. eggPlant Performance uses the time difference between the events to calculate the timing with the specifiedid
.Timings are similar to transactions but are measured and grouped separately in test results.
If the timing failed, then it will be counted separately in Test Controller and Analyzer.
- Parameters:
id
- the timing identifierpass
-true
if the timing should be interpreted as a pass- Throws:
java.lang.Exception
- An error occurred- See Also:
startTiming(String)
-
failTiming
public void failTiming(java.lang.String id) throws java.lang.Exception
Writes a fail timing event to the VU event log.The time in milliseconds since the start of the test run is recorded when this method is called. The
startTiming(String)
method should already have been called with the sameid
. eggPlant Performance uses the time difference between the events to calculate the timing with the specifiedid
.This timing will be interpreted as having failed, so it will be counted separately in Test Controller and Analyzer. This is equivalent to calling
endTiming(String, boolean)
with a pass value offalse
.Timings are similar to transactions but are measured and grouped separately in test results.
- Parameters:
id
- the timing identifier- Throws:
java.lang.Exception
- An error occurred
-
writeMessage
public void writeMessage(java.lang.String message) throws java.lang.Exception
Writes an information message to the VU event log.- Parameters:
message
- an information message which appears in the Info column- Throws:
java.lang.Exception
- An error occurred
-
writeMessage
public void writeMessage(java.lang.String id, java.lang.String message) throws java.lang.Exception
Writes an information message to the VU event log, specifying an identifier which appears in the ID column.- Parameters:
id
- the message identifier, which appears in the ID columnmessage
- an information message which appears in the Info column- Throws:
java.lang.Exception
- An error occurred
-
writeMessage
public void writeMessage(java.lang.Exception e) throws java.lang.Exception
Write an information message to the VU event log, consisting of the exception specified.- Parameters:
e
- The exception to write to the event log.- Throws:
java.lang.Exception
- An error occurred
-
writeMessage
public void writeMessage(java.lang.String id, java.lang.String info, java.lang.String imagePath) throws java.lang.Exception
Writes an information message to the VU event log and also a link to an image, specifying an identifier which appears in the ID column.The image must be contained within the run directory (as returned by
getRunPath()
, and the path passed should be relative to this path.- Parameters:
id
- the message identifier, which appears in the ID columninfo
- an information message which appears in the Info columnimagePath
- the path to an image file (such as a png or bmp). The path should be a relative path.- Throws:
java.lang.Exception
- An error occurred
-
getGroupSizes
public final com.facilita.fc.runtime.SimpleDataDictionary getGroupSizes()
Gets the number of Virtual Users in each Virtual User group.e.g.
// get the number of Virtual Users in the group "G1" int groupSize = getGroupSizes().getInt("G1");
- Returns:
- a
DataDictionary
in which the keys are group names and the values are the group sizes
-
getUniqueID
public final int getUniqueID()
Gets a test-wide unique identifier for this Virtual User.The first Virtual User has the identifier 1.
// pause for 1 second, every 10th VU if ((getUniqueID() % 10) == 0) { pause(1000); }
- Returns:
- the unique identifier of this Virtual User
-
getGroupSize
public final int getGroupSize() throws NoSuchValueException, BadValueException
Gets the number of Virtual Users in the group that this Virtual User belongs to.- Returns:
- the number of Virtual Users in the group that this Virtual User belongs to
- Throws:
NoSuchValueException
- Invalid group nameBadValueException
- Group name is null
-
getGroupSize
public final int getGroupSize(java.lang.String groupName) throws NoSuchValueException, BadValueException
Gets the number of Virtual Users in the specified Virtual User group.e.g.
// get the number of Virtual Users in the group "G1" int groupSize = getGroupSize("G1");
- Parameters:
groupName
- a Virtual User group- Returns:
- the size of the Virtual User group
- Throws:
NoSuchValueException
- Invalid group nameBadValueException
- Group name is null
-
getUniqueID
public final int getUniqueID(java.lang.String groupName, int index) throws BadValueException
Gets a test-wide unique identifier for a specified Virtual User within a Virtual User group.The first Virtual User has identifier 1.
e.g.
// get the unique identifier for the 5th VU in the "Supervisors" Virtual User group int vuNum = getUniqueID("Supervisors", 5);
- Parameters:
groupName
- the group nameindex
- the index of the Virtual User within the group- Returns:
- the unique identifier of the Virtual User
- Throws:
BadValueException
- Invalid group name
-
getString
public final java.lang.String getString(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns aString
value held in the dictionary.- Specified by:
getString
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
String
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.setString(String, String)
-
getString
public final java.lang.String getString(java.lang.String key, java.lang.String defaultValue) throws BadValueException
Description copied from interface:DataDictionary
Returns aString
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myString, using default value instead: abcd To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
getString
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultValue
- the value to return if thekey
is not present in the dictionary- Returns:
- a
String
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
DataDictionary.setString(String, String)
-
getInteger
public final java.lang.Integer getInteger(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns ajava.lang.Integer
value held in the dictionary.- Specified by:
getInteger
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
java.lang.Integer
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.setInteger(String, Integer)
-
getInteger
public final java.lang.Integer getInteger(java.lang.String key, java.lang.Integer defaultValue) throws BadValueException
Description copied from interface:DataDictionary
Returns ajava.lang.Integer
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myInteger, using default value instead: 1234 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
getInteger
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultValue
- the value to return if thekey
is not present in the dictionary- Returns:
- a
java.lang.Integer
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
DataDictionary.setInteger(String, Integer)
-
getInt
public final int getInt(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns anint
value held in the dictionary.- Specified by:
getInt
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- an
int
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.setInt(String, int)
-
getInt
public final int getInt(java.lang.String key, int defaultValue) throws BadValueException
Description copied from interface:DataDictionary
Returns anint
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myInt, using default value instead: 1234 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
getInt
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultValue
- the value to return if thekey
is not present in the dictionary- Returns:
- an
int
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
DataDictionary.setInt(String, int)
-
getLong
public final long getLong(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns along
value held in the dictionary.- Specified by:
getLong
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
long
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.setLong(String, long)
-
getLong
public final long getLong(java.lang.String key, long defaultValue) throws BadValueException
Description copied from interface:DataDictionary
Returns along
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myLong, using default value instead: 1234567890L To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
getLong
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultValue
- the value to return if thekey
is not present in the dictionary- Returns:
- a
long
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
DataDictionary.setLong(String, long)
-
getFloat
public final float getFloat(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns afloat
value held in the dictionary.- Specified by:
getFloat
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
float
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.setFloat(String, float)
-
getFloat
public final float getFloat(java.lang.String key, float defaultValue) throws BadValueException
Description copied from interface:DataDictionary
Returns afloat
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myFloat, using default value instead: 3.142F To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
getFloat
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultValue
- the value to return if thekey
is not present in the dictionary- Returns:
- a
float
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
DataDictionary.setFloat(String, float)
-
getDouble
public final double getDouble(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns adouble
value held in the dictionary.- Specified by:
getDouble
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
double
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.setDouble(String, double)
-
getDouble
public final double getDouble(java.lang.String key, double defaultValue) throws BadValueException
Description copied from interface:DataDictionary
Returns adouble
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myDouble, using default value instead: 1.234 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
getDouble
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultValue
- the value to return if thekey
is not present in the dictionary- Returns:
- a
double
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
DataDictionary.setDouble(String, double)
-
getBoolean
public final boolean getBoolean(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns aboolean
value held in the dictionary.- Specified by:
getBoolean
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
boolean
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.setBoolean(String, boolean)
-
getBoolean
public final boolean getBoolean(java.lang.String key, boolean defaultValue) throws BadValueException
Description copied from interface:DataDictionary
Returns aboolean
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myBoolean, using default value instead: true To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
getBoolean
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultValue
- the value to return if thekey
is not present in the dictionary- Returns:
- a
boolean
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
DataDictionary.setBoolean(String, boolean)
-
get
public final <T> T get(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns a reference to anObject
held in the dictionary.- Specified by:
get
in interfaceDataDictionary
- Type Parameters:
T
- The type of object to retrieve from the dictionary- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- an
Object
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.set(String, Object)
-
get
public final java.lang.Object get(java.lang.String key, java.lang.Object defaultValue) throws BadValueException
Description copied from interface:DataDictionary
Returns anObject
value held in the dictionary, or thedefaultValue
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultValue
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myObject, using default value instead: abcd1234 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
get
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultValue
- the value to return if thekey
is not present in the dictionary- Returns:
- an
Object
value held in the dictionary, or thedefaultValue
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null
-
setString
public final void setString(java.lang.String key, java.lang.String string) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets aString
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setString("hostName", "www.testplant.com");
- Specified by:
setString
in interfaceDataDictionary
- Parameters:
key
- the key to associate withstring
in the dictionarystring
- theString
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.getString(String)
-
setInteger
public final void setInteger(java.lang.String key, java.lang.Integer i) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets anInteger
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setInteger("port", 8080);
- Specified by:
setInteger
in interfaceDataDictionary
- Parameters:
key
- the key to associate withi
in the dictionaryi
- theInteger
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.getInteger(String)
-
setInt
public final void setInt(java.lang.String key, int i) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets anint
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setInt("port", 8080);
- Specified by:
setInt
in interfaceDataDictionary
- Parameters:
key
- the key to associate withi
in the dictionaryi
- theint
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.getInt(String)
-
set
public final <T> void set(java.lang.String key, T o) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets anObject
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
set("today", new Date());
- Specified by:
set
in interfaceDataDictionary
- Type Parameters:
T
- The type of object to add to the dictionary- Parameters:
key
- the key to associate witho
in the dictionaryo
- theObject
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.get(String)
-
setDouble
public final void setDouble(java.lang.String key, double i) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets adouble
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setDouble("amount", 123.45);
- Specified by:
setDouble
in interfaceDataDictionary
- Parameters:
key
- the key to associate withi
in the dictionaryi
- thedouble
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.getDouble(String)
-
setFloat
public final void setFloat(java.lang.String key, float i) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets afloat
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setFloat("amount", 123.45);
- Specified by:
setFloat
in interfaceDataDictionary
- Parameters:
key
- the key to associate withi
in the dictionaryi
- thefloat
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.getFloat(String)
-
setLong
public final void setLong(java.lang.String key, long i) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets along
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setLong("amount", 9156598231230);
- Specified by:
setLong
in interfaceDataDictionary
- Parameters:
key
- the key to associate withi
in the dictionaryi
- thelong
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.getLong(String)
-
getList
public final java.util.List getList(java.lang.String key, java.util.List defaultList) throws BadValueException
Description copied from interface:DataDictionary
Returns aList
value held in the dictionary, or thedefaultList
if thekey
cannot be found.Default data warning:
When called from a VU script, if thedefaultList
is returned then a message is also written to the VU Event Log. This feature helps highlight problems with data bindings when data is expected to come from a data source, but the default value is returned instead.An example of the message entry in the Event Log:
Type ID Info Message Default data warning No value found for key: myList, using default value instead: List with first item: Item01 To turn this feature off, go to the Test view in eggPlant Performance Studio and uncheck the option "Enable default data warnings" on the Data tab.
- Specified by:
getList
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionarydefaultList
- the value to return if thekey
is not present in the dictionary- Returns:
- a
List
value held in the dictionary, or thedefaultList
if thekey
cannot be found - Throws:
BadValueException
- thekey
was null- See Also:
DataDictionary.setList(String, List)
-
getList
public final java.util.List getList(java.lang.String key) throws NoSuchValueException, BadValueException
Description copied from interface:DataDictionary
Returns aList
value held in the dictionary.- Specified by:
getList
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
- a
List
value held in the dictionary - Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null- See Also:
DataDictionary.setList(String, List)
-
setList
public final void setList(java.lang.String key, java.util.List list) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets aList
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
List<String> hostList = new ArrayList<String>(); hostList.add("www.testplant.com"); setList("hosts", hostList);
- Specified by:
setList
in interfaceDataDictionary
- Parameters:
key
- the key to associate withlist
in the dictionarylist
- theList
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.getList(String)
-
add
public final void add(DataDictionary d) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Merges the specifiedDataDictionary
into thisDataDictionary
.All keys and values are added to this
DataDictionary
. Any keys which already exist in thisDataDictionary
will have their values replaced.- Specified by:
add
in interfaceDataDictionary
- Parameters:
d
- theDataDictionary
to be merged- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- Tried to a dd a null value to the dictionary
-
setBoolean
public final void setBoolean(java.lang.String key, boolean b) throws NotAllowedException, BadValueException
Description copied from interface:DataDictionary
Sets aboolean
value in the dictionary.key
is associated with the value in the dictionary. If thekey
already exists in the dictionary then the old value is replaced by the new value, otherwise a new key/value pair is added to the dictionary.e.g.
setBoolean("retryLogon", false);
- Specified by:
setBoolean
in interfaceDataDictionary
- Parameters:
key
- the key to associate withb
in the dictionaryb
- theboolean
to be associated with thekey
in the dictionary- Throws:
NotAllowedException
- This dictionary is read onlyBadValueException
- thekey
was null- See Also:
DataDictionary.getBoolean(String)
-
keys
public final java.util.Iterator keys()
Description copied from interface:DataDictionary
Returns anIterator
that can be used to iterate over the keys in this dictionary.- Specified by:
keys
in interfaceDataDictionary
- Returns:
- an
Iterator
that can be used to iterate over the keys in this dictionary
-
setName
public final void setName(java.lang.String name)
Description copied from interface:DataDictionary
Sets the name of this dictionary.- Specified by:
setName
in interfaceDataDictionary
- Parameters:
name
- the name of the Data Dictionary
-
isReadOnly
public final boolean isReadOnly()
Description copied from interface:DataDictionary
Returnstrue
if this dictionary is read-only.- Specified by:
isReadOnly
in interfaceDataDictionary
- Returns:
true
if this dictionary is read-only
-
getName
public final java.lang.String getName()
Description copied from interface:DataDictionary
Gets the name of this dictionary.- Specified by:
getName
in interfaceDataDictionary
- Returns:
- the name of the Data Dictionary
-
getMap
public final java.util.Map getMap()
Description copied from interface:DataDictionary
Gets aMap
containing all the keys/values in this dictionary.- Specified by:
getMap
in interfaceDataDictionary
- Returns:
- a
Map
containing all the keys/values in this dictionary
-
logCurrentDataValues
public void logCurrentDataValues() throws java.lang.Exception
Write all of the current data values to the VU event log- Throws:
java.lang.Exception
- An error occurred- See Also:
writeMessage(String)
-
toString
public final java.lang.String toString()
Description copied from interface:DataDictionary
Returns aString
representation of the dictionary.- Specified by:
toString
in interfaceDataDictionary
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a
String
representing the key/value pairs in the dictionary
-
whereAmI
public java.lang.String whereAmI()
Returns a stack trace for this Virtual User.- Returns:
- a stack trace for this Virtual User
-
hasKey
public boolean hasKey(java.lang.String key)
Description copied from interface:DataDictionary
Returnstrue
if the specifiedkey
is contained within the dictionary.e.g.
if (myDictionary.HasKey("newHostName")) { // do something } else { // do something else }
- Specified by:
hasKey
in interfaceDataDictionary
- Parameters:
key
- the key to be looked up in the dictionary- Returns:
true
if the dictionary contains the specifiedkey
-
fail
public final void fail(java.lang.String message, boolean throwException) throws java.lang.Exception
Writes a fail event to the VU event log.- Parameters:
message
- a failure message which appears in the Info columnthrowException
-true
if anFCException
should be thrown- Throws:
java.lang.Exception
- An error occurred
-
verify
public boolean verify(boolean arg, boolean throwException) throws java.lang.Exception
Verifies that a boolean expression istrue
.- Parameters:
arg
- the expression to evaluatethrowException
-true
if anFCException
should be thrown if the expression evaluates tofalse
- Returns:
true
if the expression evaluates totrue
- Throws:
java.lang.Exception
- An error occurred
-
verifyEQ
public final boolean verifyEQ(java.lang.String arg1, java.lang.String arg2, boolean throwException, boolean caseInsensitive) throws java.lang.Exception
Verifies that twoString
objects are equal.- Parameters:
arg1
- the 1stString
arg2
- the 2ndString
throwException
-true
if anFCException
should be thrown if theString
objects are not equalcaseInsensitive
-true
if the comparison should be case-insensitive- Returns:
true
if theString
objects are equal- Throws:
java.lang.Exception
- An error occurred
-
verifyEQ
public final boolean verifyEQ(int arg1, int arg2, boolean throwException) throws java.lang.Exception
Verifies that two integers are equal.- Parameters:
arg1
- the 1st integerarg2
- the 2nd integerthrowException
-true
if anFCException
should be thrown if the integers are not equal- Returns:
true
if the integers are equal- Throws:
java.lang.Exception
- An error occurred
-
verifyEQ
public final boolean verifyEQ(long arg1, long arg2, boolean throwException) throws java.lang.Exception
Verifies that two longs are equal.- Parameters:
arg1
- the 1st longarg2
- the 2nd longthrowException
-true
if anFCException
should be thrown if the longs are not equal- Returns:
true
if the longs are equal- Throws:
java.lang.Exception
- An error occurred
-
verifyEQ
public final boolean verifyEQ(double arg1, double arg2, double delta, boolean throwException) throws java.lang.Exception
Verifies that two doubles are equal.- Parameters:
arg1
- the 1st doublearg2
- the 2nd doubledelta
- the maximum permitted difference between the two valuesthrowException
-true
if anFCException
should be thrown if the doubles are not equal- Returns:
true
if the doubles are equal- Throws:
java.lang.Exception
- An error occurred
-
verifyLT
public final boolean verifyLT(java.lang.String arg1, java.lang.String arg2, boolean throwException, boolean caseInsensitive) throws java.lang.Exception
Verifies that oneString
is less than another.- Parameters:
arg1
- the 1stString
arg2
- the 2ndString
throwException
-true
if anFCException
should be thrown if the 1stString
is not less than the 2ndString
caseInsensitive
-true
if the comparison should be case-insensitive- Returns:
true
if the 1stString
is less than the 2ndString
- Throws:
java.lang.Exception
- An error occurred
-
verifyLT
public final boolean verifyLT(int arg1, int arg2, boolean throwException) throws java.lang.Exception
Verifies that one integer is less than another.- Parameters:
arg1
- the 1st integerarg2
- the 2nd integerthrowException
-true
if anFCException
should be thrown if the 1st integer is not less than the 2nd integer- Returns:
true
if the 1st integer is less than the 2nd integer- Throws:
java.lang.Exception
- An error occurred
-
verifyLT
public final boolean verifyLT(long arg1, long arg2, boolean throwException) throws java.lang.Exception
Verifies that one long is less than another.- Parameters:
arg1
- the 1st longarg2
- the 2nd longthrowException
-true
if anFCException
should be thrown if the 1st long is not less than the 2nd long- Returns:
true
if the 1st long is less than the 2nd long- Throws:
java.lang.Exception
- An error occurred
-
verifyLT
public final boolean verifyLT(double arg1, double arg2, double delta, boolean throwException) throws java.lang.Exception
Verifies that one double is less than another.- Parameters:
arg1
- the 1st doublearg2
- the 2nd doubledelta
- the maximum permitted difference between the valuesthrowException
-true
if anFCException
should be thrown if the 1st double is not less than the 2nd double- Returns:
true
if the 1st double is less than the 2nd double- Throws:
java.lang.Exception
- An error occurred
-
verifyLE
public final boolean verifyLE(java.lang.String arg1, java.lang.String arg2, boolean throwException, boolean caseInsensitive) throws java.lang.Exception
Verifies that oneString
is less than or equal to another.- Parameters:
arg1
- the 1stString
arg2
- the 2ndString
throwException
-true
if anFCException
should be thrown if the 1stString
is not less than or equal to the 2ndString
caseInsensitive
-true
if the comparison should be case-insensitive- Returns:
true
if the 1stString
is less than or equal to the 2ndString
- Throws:
java.lang.Exception
- An error occurred
-
verifyLE
public final boolean verifyLE(int arg1, int arg2, boolean throwException) throws java.lang.Exception
Verifies that one integer is less than or equal to another.- Parameters:
arg1
- the 1st integerarg2
- the 2nd integerthrowException
-true
if anFCException
should be thrown if the 1st integer is not less than or equal to the 2nd integer- Returns:
true
if the 1st integer is less than or equal to the 2nd integer- Throws:
java.lang.Exception
- An error occurred
-
verifyLE
public final boolean verifyLE(long arg1, long arg2, boolean throwException) throws java.lang.Exception
Verifies that one long is less than or equal to another.- Parameters:
arg1
- the 1st longarg2
- the 2nd longthrowException
-true
if anFCException
should be thrown if the 1st long is not less than or equal to the 2nd long- Returns:
true
if the 1st long is less than or equal to the 2nd long- Throws:
java.lang.Exception
- An error occurred
-
verifyLE
public final boolean verifyLE(double arg1, double arg2, double delta, boolean throwException) throws java.lang.Exception
Verifies that one double is less than or equal to another.- Parameters:
arg1
- the 1st doublearg2
- the 2nd doubledelta
- the maximum permitted difference between the valuesthrowException
-true
if anFCException
should be thrown if the 1st double is not less than or equal to the 2nd double- Returns:
true
if the 1st double is less than or equal to the 2nd double- Throws:
java.lang.Exception
- An error occurred
-
getVUName
public java.lang.String getVUName()
Gets the name of the group that this Virtual User belongs to.- Returns:
- the Virtual User group name
-
getSandboxPath
public java.lang.String getSandboxPath() throws NoSuchValueException, BadValueException
Gets the path to the sandbox location.The sandbox is the root location on an injector machine beneath which all test run files are stored. This includes files transferred from the controller machine (project/workspace dlls and jars, data) and test run results and events written during test execution.
- Returns:
- the path to the sandbox location
- Throws:
NoSuchValueException
- Unable to find sandbox pathBadValueException
- Sandbox path is null
-
getDataPath
public java.lang.String getDataPath() throws NoSuchValueException, BadValueException
Gets the path to the data folder.This is the folder on an injector machine to which data files are transferred from the controller machine. Files in this folder are only transferred if explicitly assigned to a test or test group.
Note that all files in the project
data\Files
folder are copied to all injectors - seegetFilesDataPath()
.- Returns:
- the path to the data folder
- Throws:
NoSuchValueException
- Unable to find data pathBadValueException
- Data path is null
-
getFilesDataPath
public java.lang.String getFilesDataPath() throws NoSuchValueException, BadValueException
Gets the path of thedata\Files
folder.This is the folder on an injector machine to which all the files in the
data\Files
folder on the controller machine are transferred.- Returns:
- the path of the
data\Files
folder - Throws:
NoSuchValueException
- Unable to find data pathBadValueException
- Data path is null
-
getRunPath
public java.lang.String getRunPath()
Gets the path to the test run results.The run path is the disk location on an injector machine to which Virtual User event files and logs are written.
- Returns:
- the path to the test run results
-
startRequest
public void startRequest(java.lang.String request) throws java.lang.Exception
For internal use only.- Parameters:
request
- internal use only- Throws:
java.lang.Exception
- An error occurred
-
endRequest
public void endRequest(java.lang.String request) throws java.lang.Exception
For internal use only.- Parameters:
request
- internal use only- Throws:
java.lang.Exception
- An error occurred
-
endRequest
public void endRequest(java.lang.String request, MetricCollection metrics) throws java.lang.Exception
For internal use only.- Parameters:
request
- internal use onlymetrics
- internal use only- Throws:
java.lang.Exception
- An error occurred
-
recordMetric
public void recordMetric(java.lang.String name, int value) throws java.lang.Exception
Records a user metric.This can be any numeric value which is considered relevant to the test, such as the number of search results returned by a web page, or a count of files in a directory.
The metric value is written to the Virtual User event log. A chart showing how the metric value changes during the test will be available in Test Controller and Analyzer.
- Parameters:
name
- the metric identifiervalue
- the metric value- Throws:
java.lang.Exception
- An error occurred
-
recordMetrics
public void recordMetrics(MetricCollection metrics) throws java.lang.Exception
Records multiple user metrics simultaneously.These can be any numeric value which is considered relevant to the test, such as the number of search results returned by a web page, or a count of files in a directory.
Each metric value is written to the Virtual User event log. A chart showing how the metric values change during the test will be available in Test Controller and Analyzer.
- Parameters:
metrics
- the collection of metrics to record- Throws:
java.lang.Exception
- An error occurred- See Also:
recordMetric(String, int)
-
recordTransaction
public void recordTransaction(java.lang.String id, int startTime, int duration, boolean pass) throws java.lang.Exception
Records a transaction in the VU event log, specifying whether the transaction passed.The recommended way to record a transaction is by using the
startTransaction(String)
andendTransaction(String)
methods.However this method is useful if you need to measure a transaction but the start time and/or the transaction name are not known at the point the transaction starts. For example, you may wish to record a different transaction name depending on the result of a particular call to the SUT.
e.g.
int startTime = getElapsedTime(); boolean result = doSomething(); int duration = getElapsedTime() - startTime; // Transaction name differs, depending on the result of the call if (result) { recordTransaction("transaction1", startTime, duration, true); } else { recordTransaction("transaction2", startTime, duration, false); }
- Parameters:
id
- the transaction identifierstartTime
- the time at which the transaction started, measured in milliseconds since the start of the test runduration
- the duration of the transaction, in millisecondspass
-true
if the transaction should be interpreted as a pass- Throws:
java.lang.Exception
- An error occurred
-
recordTransaction
public void recordTransaction(java.lang.String id, int startTime, int duration) throws java.lang.Exception
Records a transaction in the VU event log.The recommended way to record a transaction is by using the
startTransaction(String)
andendTransaction(String)
methods.However this method is useful if you need to measure a transaction but the start time and/or the transaction name are not known at the point the transaction starts. For example, you may wish to record a different transaction name depending on the result of a particular call to the SUT.
e.g.
int startTime = getElapsedTime(); boolean result = doSomething(); int duration = getElapsedTime() - startTime; // Transaction name differs, depending on the result of the call if (result) { recordTransaction("transaction1", startTime, duration); } else { recordTransaction("transaction2", startTime, duration); }
- Parameters:
id
- the transaction identifierstartTime
- the time at which the transaction started, measured in milliseconds since the start of the test runduration
- the duration of the transaction, in milliseconds- Throws:
java.lang.Exception
- An error occurred
-
recordTransaction
public void recordTransaction(java.lang.String id, java.util.Date startTime, int duration, boolean pass) throws java.lang.Exception
Records a transaction in the VU event log, specifying whether the transaction passed.The recommended way to record a transaction is by using the
startTransaction(String)
andendTransaction(String, boolean)
methods.However this method is useful if you need to measure a transaction but the start time and/or the transaction name are not known at the point the transaction starts. For example, you may wish to record a different transaction name depending on the result of a particular call to the SUT.
e.g.
Date startTime = new Date(); boolean result = doSomething(); int duration = (int)(new Date().getTime() - startTime.getTime()); // Transaction name differs, depending on the result of the call if (result) { recordTransaction("transaction1", startTime, duration, true); } else { recordTransaction("transaction2", startTime, duration, false); }
- Parameters:
id
- the transaction identifierstartTime
- the time at which the transaction startedduration
- the duration of the transaction, in millisecondspass
-true
if the transaction should be interpreted as a pass- Throws:
java.lang.Exception
- An error occurred
-
recordTransaction
public void recordTransaction(java.lang.String id, java.util.Date startTime, int duration) throws java.lang.Exception
Records a transaction in the VU event log.The recommended way to record a transaction is by using the
startTransaction(String)
andendTransaction(String)
methods.However this method is useful if you need to measure a transaction but the start time and/or the transaction name are not known at the point the transaction starts. For example, you may wish to record a different transaction name depending on the result of a particular call to the SUT.
e.g.
Date startTime = new Date(); boolean result = doSomething(); int duration = (int)(new Date().getTime() - startTime.getTime()); // Transaction name differs, depending on the result of the call if (result) { recordTransaction("transaction1", startTime, duration); } else { recordTransaction("transaction2", startTime, duration); }
- Parameters:
id
- the transaction identifierstartTime
- the time at which the transaction startedduration
- the duration of the transaction, in milliseconds- Throws:
java.lang.Exception
- An error occurred
-
getMillisecondsSinceEpoch
public static java.lang.String getMillisecondsSinceEpoch()
-
getMillisecondsSinceEpoch
public static java.lang.String getMillisecondsSinceEpoch(long offset)
-
getSecondsSinceEpoch
public static java.lang.String getSecondsSinceEpoch()
-
getSecondsSinceEpoch
public static java.lang.String getSecondsSinceEpoch(long offset)
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.Duration offset, java.time.ZoneId timezone, java.util.Locale locale)
Converts a LocalDateTime object to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", LocalDateTime.of(2017, 9, 15, 7, 41, 25), Duration.ofHours(1), ZoneId.of("Asia/Tokyo"), Locale.FRENCH);
- Parameters:
format
- The date and time format stringdateTime
- The LocalDateTime object to be represented as a stringoffset
- An offset to apply to the DateTime object before it is formattedtimezone
- The time zone to uselocale
- The locale to use- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format)
Converts the current date/time to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy");
- Parameters:
format
- The date and time format string- Returns:
- A string representation of the current date/time
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime)
Converts a LocalDateTime object to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", LocalDateTime.of(2017, 9, 15, 7, 41, 25));
- Parameters:
format
- The date and time format stringdateTime
- The LocalDateTime object to be represented as a string- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.Duration offset)
Converts the current date/time, offset by a specified Duration, to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", Duration.ofHours(1));
- Parameters:
format
- The date and time format stringoffset
- An offset to apply to the DateTime object before it is formatted- Returns:
- A string representation of the current date/time
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.ZoneId timezone)
Converts the current date/time to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", ZoneId.of("Asia/Tokyo"));
- Parameters:
format
- The date and time format stringtimezone
- The time zone to use- Returns:
- A string representation of the current date/time
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.util.Locale locale)
Converts the current date/time to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", Locale.FRENCH);
- Parameters:
format
- The date and time format stringlocale
- The locale to use- Returns:
- A string representation of the current date/time
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.Duration offset)
Converts a LocalDateTime object to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", LocalDateTime.of(2017, 9, 15, 7, 41, 25), Duration.ofHours(1));
- Parameters:
format
- The date and time format stringdateTime
- The LocalDateTime object to be represented as a stringoffset
- An offset to apply to the DateTime object before it is formatted- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.ZoneId timezone)
Converts a LocalDateTime object to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", LocalDateTime.of(2017, 9, 15, 7, 41, 25), ZoneId.of("Asia/Tokyo"));
- Parameters:
format
- The date and time format stringdateTime
- The LocalDateTime object to be represented as a stringtimezone
- The time zone to use- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.util.Locale locale)
Converts a LocalDateTime object to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", LocalDateTime.of(2017, 9, 15, 7, 41, 25), Locale.FRENCH);
- Parameters:
format
- The date and time format stringdateTime
- The LocalDateTime object to be represented as a stringlocale
- The locale to use- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.Duration offset, java.time.ZoneId timezone)
Converts the current date/time to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", Duration.ofHours(1), ZoneId.of("Asia/Tokyo"));
- Parameters:
format
- The date and time format stringoffset
- An offset to apply to the DateTime object before it is formattedtimezone
- The time zone to use- Returns:
- A string representation of the current date/time
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.Duration offset, java.util.Locale locale)
Converts the current date/time to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", Duration.ofHours(1), Locale.FRENCH);
- Parameters:
format
- The date and time format stringoffset
- An offset to apply to the DateTime object before it is formattedlocale
- The locale to use- Returns:
- A string representation of the current date/time
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.ZoneId timezone, java.util.Locale locale)
Converts the current date/time to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", ZoneId.of("Asia/Tokyo"), Locale.FRENCH);
- Parameters:
format
- The date and time format stringtimezone
- The time zone to uselocale
- The locale to use- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.Duration offset, java.time.ZoneId timezone)
Converts a LocalDateTime object to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", LocalDateTime.of(2017, 9, 15, 7, 41, 25), Duration.ofHours(1), ZoneId.of("Asia/Tokyo"));
- Parameters:
format
- The date and time format stringdateTime
- The LocalDateTime object to be represented as a stringoffset
- An offset to apply to the DateTime object before it is formattedtimezone
- The time zone to use- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.Duration offset, java.util.Locale locale)
Converts a LocalDateTime object to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", LocalDateTime.of(2017, 9, 15, 7, 41, 25), Duration.ofHours(1), Locale.FRENCH);
- Parameters:
format
- The date and time format stringdateTime
- The LocalDateTime object to be represented as a stringoffset
- An offset to apply to the DateTime object before it is formattedlocale
- The locale to use- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.LocalDateTime dateTime, java.time.ZoneId timezone, java.util.Locale locale)
Converts a LocalDateTime object to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", LocalDateTime.of(2017, 9, 15, 7, 41, 25), ZoneId.of("Asia/Tokyo"), Locale.FRENCH);
- Parameters:
format
- The date and time format stringdateTime
- The LocalDateTime object to be represented as a stringtimezone
- The time zone to uselocale
- The locale to use- Returns:
- A string representation of the LocalDateTime
-
formatDateTime
public static java.lang.String formatDateTime(java.lang.String format, java.time.Duration offset, java.time.ZoneId timezone, java.util.Locale locale)
Converts the current date/time to its equivalent string representation using the specified format.The format string should be a standard date and time format string, as described here
Example:
String formattedDateTime = formatDateTime("HH:mm:ss MM/dd/yyyy", Duration.ofHours(1), ZoneId.of("Asia/Tokyo"), Locale.FRENCH);
- Parameters:
format
- The date and time format stringoffset
- An offset to apply to the DateTime object before it is formattedtimezone
- The time zone to uselocale
- The locale to use- Returns:
- A string representation of the LocalDateTime
-
getCurrentTimeInXml
public static javax.xml.datatype.XMLGregorianCalendar getCurrentTimeInXml() throws javax.xml.datatype.DatatypeConfigurationException
- Throws:
javax.xml.datatype.DatatypeConfigurationException
-
getTransactionData
public TransactionData getTransactionData(java.lang.String id) throws NoSuchValueException
Get data about the specified transaction.- Parameters:
id
- The id of the transaction- Returns:
- data about the specified transaction.
- Throws:
NoSuchValueException
- The transaction cannot be found
-
getService
public com.facilita.fc.runtime.Service getService(java.lang.Class<com.facilita.fc.runtime.Service> serviceClass) throws NoSuchValueException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
Get aService
object of the specified type- Parameters:
serviceClass
- the type ofService
object to get- Returns:
- a
Service
object of the specified type - Throws:
NoSuchValueException
- Unknown service classjava.lang.NoSuchMethodException
- Failed to construct service instancejava.lang.SecurityException
- Failed to construct service instancejava.lang.InstantiationException
- Failed to construct service instancejava.lang.IllegalAccessException
- Failed to construct service instancejava.lang.IllegalArgumentException
- Failed to construct service instancejava.lang.reflect.InvocationTargetException
- Failed to construct service instance
-
setSynchronizationPoint
public void setSynchronizationPoint(java.lang.String id)
Set a named synchronization point.Any threads that are waiting for this synchronization point will be allowed to continue.
- Parameters:
id
- the name of the synchronization point to set.- See Also:
unsetSynchronizationPoint(String)
,waitForSynchronizationPoint(String, long)
-
unsetSynchronizationPoint
public void unsetSynchronizationPoint(java.lang.String id)
Unset a named synchronization point.Any threads that are waiting for this synchronization point will not be allowed to continue until the synchronization point is set
- Parameters:
id
- the name of the synchronization point to unset- See Also:
setSynchronizationPoint(String)
,waitForSynchronizationPoint(String, long)
-
waitForSynchronizationPoint
public void waitForSynchronizationPoint(java.lang.String id, long timeoutMilliseconds) throws com.facilita.exception.TimeoutException
Wait for a named synchronization point to be set.This method will block until either the named synchronization point is set, or the timeout period has elapsed. If the timeout period elapses before the synchronization point is set then an exception will be thrown.
- Parameters:
id
- the name of the synchronization point to wait fortimeoutMilliseconds
- the maximum time in milliseconds to wait before throwing an exception- Throws:
com.facilita.exception.TimeoutException
- thrown if the synchronization point has not been set before the timeout period elapses.- See Also:
setSynchronizationPoint(String)
,unsetSynchronizationPoint(String)
-
waitFor
public <T> T waitFor(java.lang.String key, long timeout) throws com.facilita.exception.TimeoutException, NoSuchValueException, BadValueException
Returns a reference to an object stored in the data dictionary. If the object is not yet in the data dictionary, then this method will wait for up to thetimeout
for the object to be added. For example, a foreground script may need to wait for a background script to put an object into the data dictionary before continuing.- Type Parameters:
T
- The type of the object to retreive from the data dictionary.- Parameters:
key
- The key to be looked up in the dictionary.timeout
- The maximum amount of time (milliseconds) to wait for the object to be added to the dictionary.- Returns:
- An
object
value held in the dictionary. - Throws:
com.facilita.exception.TimeoutException
- The object was not put into the dictionary in timeNoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
waitForString
public java.lang.String waitForString(java.lang.String key, long timeout) throws com.facilita.exception.TimeoutException, NoSuchValueException, BadValueException
Returns a reference to a String stored in the data dictionary. If the String is not yet in the data dictionary, then this method will wait for up to thetimeout
for the String to be added. For example, a foreground script may need to wait for a background script to put a String into the data dictionary before continuing.- Parameters:
key
- The key to be looked up in the dictionary.timeout
- The maximum amount of time (milliseconds) to wait for the String to be added to the dictionary.- Returns:
- A
String
value held in the dictionary. - Throws:
com.facilita.exception.TimeoutException
- The String was not put into the dictionary in timeNoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
waitForInt
public int waitForInt(java.lang.String key, long timeout) throws com.facilita.exception.TimeoutException, NoSuchValueException, BadValueException
Returns an int stored in the data dictionary. If the int is not yet in the data dictionary, then this method will wait for up to thetimeout
for the int to be added. For example, a foreground script may need to wait for a background script to put an int into the data dictionary before continuing.- Parameters:
key
- The key to be looked up in the dictionary.timeout
- The maximum amount of time (milliseconds) to wait for the int to be added to the dictionary.- Returns:
- A
int
value held in the dictionary. - Throws:
com.facilita.exception.TimeoutException
- The int was not put into the dictionary in timeNoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
waitForBoolean
public boolean waitForBoolean(java.lang.String key, long timeout) throws com.facilita.exception.TimeoutException, NoSuchValueException, BadValueException
Returns a boolean stored in the data dictionary. If the boolean is not yet in the data dictionary, then this method will wait for up to thetimeout
for the boolean to be added. For example, a foreground script may need to wait for a background script to put a boolean into the data dictionary before continuing.- Parameters:
key
- The key to be looked up in the dictionary.timeout
- The maximum amount of time (milliseconds) to wait for the boolean to be added to the dictionary.- Returns:
- A
boolean
value held in the dictionary. - Throws:
com.facilita.exception.TimeoutException
- The boolean was not put into the dictionary in timeNoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
waitForDouble
public double waitForDouble(java.lang.String key, long timeout) throws com.facilita.exception.TimeoutException, NoSuchValueException, BadValueException
Returns a double stored in the data dictionary. If the double is not yet in the data dictionary, then this method will wait for up to thetimeout
for the double to be added. For example, a foreground script may need to wait for a background script to put a double into the data dictionary before continuing.- Parameters:
key
- The key to be looked up in the dictionary.timeout
- The maximum amount of time (milliseconds) to wait for the double to be added to the dictionary.- Returns:
- A
double
value held in the dictionary. - Throws:
com.facilita.exception.TimeoutException
- The double was not put into the dictionary in timeNoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
waitForFloat
public float waitForFloat(java.lang.String key, long timeout) throws com.facilita.exception.TimeoutException, NoSuchValueException, BadValueException
Returns a float stored in the data dictionary. If the float is not yet in the data dictionary, then this method will wait for up to thetimeout
for the float to be added. For example, a foreground script may need to wait for a background script to put a float into the data dictionary before continuing.- Parameters:
key
- The key to be looked up in the dictionary.timeout
- The maximum amount of time (milliseconds) to wait for the float to be added to the dictionary.- Returns:
- A
float
value held in the dictionary. - Throws:
com.facilita.exception.TimeoutException
- The float was not put into the dictionary in timeNoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
waitForList
public java.util.List waitForList(java.lang.String key, long timeout) throws com.facilita.exception.TimeoutException, NoSuchValueException, BadValueException
Returns a reference to a List stored in the data dictionary. If the List is not yet in the data dictionary, then this method will wait for up to thetimeout
for the List to be added. For example, a foreground script may need to wait for a background script to put a List into the data dictionary before continuing.- Parameters:
key
- The key to be looked up in the dictionary.timeout
- The maximum amount of time (milliseconds) to wait for the List to be added to the dictionary.- Returns:
- A
List
value held in the dictionary. - Throws:
com.facilita.exception.TimeoutException
- The List was not put into the dictionary in timeNoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
waitForLong
public long waitForLong(java.lang.String key, long timeout) throws com.facilita.exception.TimeoutException, NoSuchValueException, BadValueException
Returns a long stored in the data dictionary. If the long is not yet in the data dictionary, then this method will wait for up to thetimeout
for the long to be added. For example, a foreground script may need to wait for a background script to put a long into the data dictionary before continuing.- Parameters:
key
- The key to be looked up in the dictionary.timeout
- The maximum amount of time (milliseconds) to wait for the long to be added to the dictionary.- Returns:
- A
long
value held in the dictionary. - Throws:
com.facilita.exception.TimeoutException
- The long was not put into the dictionary in timeNoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
selectRandomEntryFromList
public <T> T selectRandomEntryFromList(java.lang.String key) throws NoSuchValueException, BadValueException
Selects a random entry from a list stored in this Virtual User's data dictionary.- Type Parameters:
T
- The type of object that is stored in the list.- Parameters:
key
- The key to be looked up in the dictionary.- Returns:
- A randomly selected entry from the list.
- Throws:
NoSuchValueException
- thekey
does not exist in the dictionaryBadValueException
- thekey
was null
-
getInjectorName
public java.lang.String getInjectorName() throws NoSuchValueException, BadValueException
Returns the injector machine name- Returns:
- the injector machine name
- Throws:
NoSuchValueException
- The injector name could not be foundBadValueException
- The injector name is null
-
getInjectorFamilyName
public java.lang.String getInjectorFamilyName() throws NoSuchValueException, BadValueException
Returns the injector family name- Returns:
- the injector family name
- Throws:
NoSuchValueException
- The injector family name could not be foundBadValueException
- The injector family name is null
-
-