Package com.xceptance.xlt.api.actions
Class AbstractAction
- java.lang.Object
-
- com.xceptance.xlt.api.actions.AbstractAction
-
- Direct Known Subclasses:
AbstractWebAction
public abstract class AbstractAction extends java.lang.Object
AbstractAction is the base class for all test actions. A test action is one step in a sequence of steps that comprise a test case.- See Also:
AbstractTestCase
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractAction(AbstractAction previousAction, java.lang.String timerName)
Creates a new AbstractAction object and gives it the passed timer name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
execute()
Executes the action.protected void
executeThinkTime()
Waits for the defined thinking time.AbstractAction
getPreviousAction()
Returns the action that was passed as the previous action to the constructor.long
getThinkTime()
Returns the currently used think time.long
getThinkTimeDeviation()
Returns the currently used think time deviation.java.lang.String
getTimerName()
Returns the name under which response time measures for this action will be recorded.protected abstract void
postValidate()
Verifies whether all post-conditions after executing the current action are fulfilled.abstract void
preValidate()
Verifies whether all pre-conditions to execute the current action are fulfilled.boolean
preValidateSafe()
Executes preValidate and catches all exceptions.void
run()
Runs the current action.void
setThinkTime(int thinkTime)
Sets the new think time.void
setThinkTime(long thinkTime)
Sets the new think time.void
setThinkTimeDeviation(int thinkTimeDeviation)
Sets the new think time deviation.void
setThinkTimeDeviation(long thinkTimeDeviation)
Sets the new think time deviation.void
setTimerName(java.lang.String timerName)
Sets the action's timer name.
-
-
-
Constructor Detail
-
AbstractAction
protected AbstractAction(AbstractAction previousAction, java.lang.String timerName)
Creates a new AbstractAction object and gives it the passed timer name. This constructor is typically used for an intermediate action in a sequence of actions, i.e. it has a previous action.- Parameters:
previousAction
- the action that preceded the current actiontimerName
- the name of the timer that is associated with this action
-
-
Method Detail
-
getPreviousAction
public AbstractAction getPreviousAction()
Returns the action that was passed as the previous action to the constructor. Allows to access data collected during the previous action.- Returns:
- the previous action (may be null)
-
getTimerName
public java.lang.String getTimerName()
Returns the name under which response time measures for this action will be recorded.- Returns:
- the timer name
-
preValidate
public abstract void preValidate() throws java.lang.Exception
Verifies whether all pre-conditions to execute the current action are fulfilled. Prevalidation will only be executed once to avoid double execution. In case of JavaScript usage or DOM changes during prevalidation, it might change the result, therefore we limit it to one execution.- Throws:
java.lang.Exception
- if an error occurred while verifying the pre-conditions
-
execute
protected abstract void execute() throws java.lang.Exception
Executes the action. What is done here is determined by the sub classes.- Throws:
java.lang.Exception
- if an error occurred while executing the action
-
postValidate
protected abstract void postValidate() throws java.lang.Exception
Verifies whether all post-conditions after executing the current action are fulfilled.- Throws:
java.lang.Exception
- if an error occurred while verifying the post-conditions
-
preValidateSafe
public boolean preValidateSafe()
Executes preValidate and catches all exceptions. Will return false in case of exceptions, true otherwise. This can be used to determine the state of the previous page without raising any errors, e.g. for checking if we could continue browsing. Means that it is not an error when the pre-conditions are not met. In case of expected exceptions (java.lang.AssertionError), no message will be issued. In case of any other exception type, the message will be logged but still caught and false is returned. Can be called as long as run() was not called. The prevalidation will only be executed once. The return value of the first execution is preserved and returned if called again.- Returns:
- true when we have no errors, false otherwise.
-
run
public void run() throws java.lang.Throwable
Runs the current action. This includes:- waiting the specified thinking time by calling executeThinkTime() if and only if this is not the 1st action
- checking the pre-conditions by calling preValidate()
- executing the current action by calling execute()
- checking the post-conditions by calling postValidate()
- Throws:
java.lang.Throwable
- if an error occurred while running the action
-
executeThinkTime
protected void executeThinkTime() throws java.lang.InterruptedException
Waits for the defined thinking time.- Throws:
java.lang.InterruptedException
-
getThinkTime
public long getThinkTime()
Returns the currently used think time.- Returns:
- the think time
-
getThinkTimeDeviation
public long getThinkTimeDeviation()
Returns the currently used think time deviation.- Returns:
- the think time deviation
-
setThinkTime
public void setThinkTime(long thinkTime)
Sets the new think time. Uses only the least 32 bit of the argument value a new value!- Parameters:
thinkTime
- the think time to set
-
setThinkTimeDeviation
public void setThinkTimeDeviation(long thinkTimeDeviation)
Sets the new think time deviation. Uses only the least 32 bit of the argument value a new value!- Parameters:
thinkTimeDeviation
- the think time deviation to set
-
setThinkTime
public void setThinkTime(int thinkTime)
Sets the new think time.- Parameters:
thinkTime
- the think time to set
-
setThinkTimeDeviation
public void setThinkTimeDeviation(int thinkTimeDeviation)
Sets the new think time deviation.- Parameters:
thinkTimeDeviation
- the think time deviation to set
-
setTimerName
public void setTimerName(java.lang.String timerName)
Sets the action's timer name.- Parameters:
timerName
- the timer name
-
-