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
AbstractWebAction is the base class for all HTTP-based actions. In order to perform requests, it relies on a web
client.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final List
<NameValuePair> An empty request parameter list. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
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 TypeMethodDescriptionvoid
addResponseProcessor
(ResponseProcessor processor) Registers the given response processor.void
Closes the underlying web client and releases all resources associated with it.protected WebRequest
createWebRequestSettings
(URL url, HttpMethod method, List<NameValuePair> requestParameters) Creates aWebRequest
object from the passed URL, request parameters and request method.Returns the action that was passed as the previous action to the constructor.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 Details
-
EMPTY_PARAMETER_LIST
An empty request parameter list. Use together withcreateWebRequestSettings(URL, HttpMethod, List)
.
-
-
Constructor Details
-
AbstractWebAction
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
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
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
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
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
The run method must restore the state in case we constructed another action in between to prevalidate conditions.- Overrides:
run
in classAbstractAction
- Throws:
Throwable
- if an error occurred while running the action
-
createWebRequestSettings
protected WebRequest createWebRequestSettings(URL url, HttpMethod method, List<NameValuePair> requestParameters) throws 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:
MalformedURLException
- if an error occurred
-