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 java.util.List<NameValuePair>
EMPTY_PARAMETER_LIST
An empty request parameter list.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractWebAction(AbstractWebAction previousAction, java.lang.String timerName)
Creates a new AbstractWebAction object and gives it the passed timer name.protected
AbstractWebAction(java.lang.String timerName)
Creates a new AbstractWebAction object and gives it the passed timer name.
-
Method Summary
All Methods Instance Methods Concrete Methods 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(java.net.URL url, HttpMethod method, java.util.List<NameValuePair> requestParameters)
Creates aWebRequest
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
-
-
-
-
Field Detail
-
EMPTY_PARAMETER_LIST
protected static final java.util.List<NameValuePair> EMPTY_PARAMETER_LIST
An empty request parameter list. Use together withcreateWebRequestSettings(URL, HttpMethod, List)
.
-
-
Constructor Detail
-
AbstractWebAction
protected AbstractWebAction(AbstractWebAction previousAction, java.lang.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 actiontimerName
- the name of the timer that is associated with this action
-
AbstractWebAction
protected AbstractWebAction(java.lang.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 Detail
-
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 multipleAbstractWebAction
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 anIllegalStateException
.
-
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 classAbstractAction
- 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:
java.lang.IllegalStateException
- if the web client has already been closed explicitly
-
run
public void run() throws java.lang.Throwable
The run method must restore the state in case we constructed another action in between to prevalidate conditions.- Overrides:
run
in classAbstractAction
- Throws:
java.lang.Throwable
- if an error occurred while running the action
-
createWebRequestSettings
protected WebRequest createWebRequestSettings(java.net.URL url, HttpMethod method, java.util.List<NameValuePair> requestParameters) throws java.net.MalformedURLException
Creates aWebRequest
object from the passed URL, request parameters and request method.- Parameters:
url
- the target URLmethod
- the HTTP request method to be usedrequestParameters
- the list of custom parameters to add- Throws:
java.net.MalformedURLException
- if an error occurred
-
-