Package com.xceptance.xlt.api.actions

# Class AbstractWebAction

java.lang.Object
com.xceptance.xlt.api.actions.AbstractAction
com.xceptance.xlt.api.actions.AbstractWebAction

Direct Known Subclasses:
  `AbstractHtmlPageAction`, `AbstractLightWeightPageAction`, `AbstractXmlPageAction`

public abstract class AbstractWebAction extends AbstractAction
AbstractWebAction is the base class for all HTTP-based actions. In order to perform requests, it relies on a web client.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final List<NameValuePair>`
  `EMPTY_PARAMETER_LIST`
  An empty request parameter list.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractWebAction(AbstractWebAction previousAction, String timerName)`
  Creates a new AbstractWebAction object and gives it the passed timer name.
  `protected`
  `AbstractWebAction(String timerName)`
  Creates a new AbstractWebAction object and gives it the passed timer name.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addResponseProcessor(ResponseProcessor processor)`
  Registers the given response processor.
  `void`
  `closeWebClient()`
  Closes the underlying web client and releases all resources associated with it.
  `protected WebRequest`
  `createWebRequestSettings(URL url, HttpMethod method, List<NameValuePair> requestParameters)`
  Creates a `WebRequest` object from the passed URL, request parameters and request method.
  `AbstractWebAction`
  `getPreviousAction()`
  Returns the action that was passed as the previous action to the constructor.
  `WebClient`
  `getWebClient()`
  Returns the current web client.
  `void`
  `run()`
  The run method must restore the state in case we constructed another action in between to prevalidate conditions.

  ### Methods inherited from class com.xceptance.xlt.api.actions.AbstractAction

  `execute, executeThinkTime, getThinkTime, getThinkTimeDeviation, getTimerName, postValidate, preValidate, preValidateSafe, setThinkTime, setThinkTime, setThinkTimeDeviation, setThinkTimeDeviation, setTimerName`

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

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

- ## Field Details

  - ### EMPTY_PARAMETER_LIST

    protected static final List<NameValuePair> EMPTY_PARAMETER_LIST
    An empty request parameter list. Use together with `createWebRequestSettings(URL, HttpMethod, List)`.

- ## Constructor Details

  - ### AbstractWebAction

    protected AbstractWebAction(AbstractWebAction previousAction, String timerName)
    Creates a new AbstractWebAction 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

  - ### AbstractWebAction

    protected AbstractWebAction(String timerName)
    Creates a new AbstractWebAction object and gives it the passed timer name. This constructor is typically used for the first action in a sequence of actions, i.e. it has no previous action.
    Parameters:
      `timerName` - the name of the timer that is associated with this action

- ## Method Details

  - ### addResponseProcessor

    public void addResponseProcessor(ResponseProcessor processor)
    Registers the given response processor. Note that the processor is valid during the current action only.
    Parameters:
      `processor` - the response processor

  - ### closeWebClient

    public void closeWebClient()
    Closes the underlying web client and releases all resources associated with it. Usually, doing this explicitly is not necessary since the framework takes care of this at the end of the test. However, if you create multiple independent web sessions (by creating multiple `AbstractWebAction` objects without a previous action) during a test, you might want to release any web session not needed any longer as soon as possible to reduce over-all memory consumption. Note that accessing the web client afterwards will cause an `IllegalStateException`.

  - ### getPreviousAction

    public AbstractWebAction getPreviousAction()
    Returns the action that was passed as the previous action to the constructor. Allows access to data collected during the previous action.
    Overrides:
      `getPreviousAction` in class `AbstractAction`
    Returns:
      the previous action (may be null)

  - ### getWebClient

    public WebClient getWebClient()
    Returns the current web client. Makes it possible to perform low-level HTTP operations directly.
    Returns:
      the current web client
    Throws:
      `IllegalStateException` - if the web client has already been closed explicitly

  - ### run

    public void run() throws Throwable
    The run method must restore the state in case we constructed another action in between to prevalidate conditions.
    Overrides:
      `run` in class `AbstractAction`
    Throws:
      `Throwable` - if an error occurred while running the action

  - ### createWebRequestSettings

    protected WebRequest createWebRequestSettings(URL url, HttpMethod method, List<NameValuePair> requestParameters) throws MalformedURLException
    Creates a `WebRequest` object from the passed URL, request parameters and request method.
    Parameters:
      `url` - the target URL
      `method` - the HTTP request method to be used
      `requestParameters` - the list of custom parameters to add
    Throws:
      `MalformedURLException` - if an error occurred