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 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, String timerName)`
  Creates a new AbstractAction object and gives it the passed timer name.

- ## Method Summary

  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.
  `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(String timerName)`
  Sets the action's timer name.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AbstractAction

    protected AbstractAction(AbstractAction previousAction, 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 action
      `timerName` - the name of the timer that is associated with this action

- ## Method Details

  - ### 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 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 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:
      `Exception` - if an error occurred while verifying the pre-conditions

  - ### execute

    protected abstract void execute() throws Exception
    Executes the action. What is done here is determined by the sub classes.
    Throws:
      `Exception` - if an error occurred while executing the action

  - ### postValidate

    protected abstract void postValidate() throws Exception
    Verifies whether all post-conditions after executing the current action are fulfilled.
    Throws:
      `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 Throwable
    Runs the current action. This includes:
    1. waiting the specified thinking time by calling executeThinkTime() if and only if this is not the 1st action
    2. checking the pre-conditions by calling preValidate()
    3. executing the current action by calling execute()
    4. checking the post-conditions by calling postValidate()
    This method can only be called once.
    Throws:
      `Throwable` - if an error occurred while running the action

  - ### executeThinkTime

    protected void executeThinkTime() throws InterruptedException
    Waits for the defined thinking time.
    Throws:
      `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(String timerName)
    Sets the action's timer name.
    Parameters:
      `timerName` - the timer name