Package com.xceptance.xlt.api.actions
Class AbstractLightWeightPageAction
- java.lang.Object
-
- com.xceptance.xlt.api.actions.AbstractAction
-
- com.xceptance.xlt.api.actions.AbstractWebAction
-
- com.xceptance.xlt.api.actions.AbstractLightWeightPageAction
-
public abstract class AbstractLightWeightPageAction extends AbstractWebAction
AbstractLightWeightPageAction is the base class for all HTML/XML-based actions which do simple page processing only. In contrast toAbstractHtmlPageAction
, the loaded page is represented as a single unparsed string. This makes it harder to pick certain elements of the page, but completely avoids the client-side overhead to parse the page and represent it as a tree of elements. Especially with complex pages, the overhead may be significantly lower this way. So this class should be used, if either the page processing is simple enough or the test clients turn out to be the bottleneck.
-
-
Field Summary
-
Fields inherited from class com.xceptance.xlt.api.actions.AbstractWebAction
EMPTY_PARAMETER_LIST
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLightWeightPageAction(AbstractWebAction previousAction, java.lang.String timerName)
Creates a new AbstractLightWeightPageAction object and gives it the passed timer name.protected
AbstractLightWeightPageAction(java.lang.String timerName)
Creates a new AbstractLightWeightPageAction object and gives it the passed timer name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getContent()
Returns the unparsed content of the web page loaded by this action.int
getHttpResponseCode()
Returns the response code of the last loaded page.LightWeightPage
getLightWeightPage()
Returns the light-weight page generated by this action.AbstractLightWeightPageAction
getPreviousAction()
Returns the action that was passed as the previous action to the constructor.java.net.URL
getURL()
Returns the URL that was used to load the page.protected void
loadPage(java.lang.String urlAsString)
Creates an URL from the passed string, loads the page using HTTP GET and stores it internally.protected void
loadPage(java.net.URL url)
Loads the page using HTTP GET from the passed URL and stores it internally.protected void
loadPage(java.net.URL url, HttpMethod method, java.util.List<NameValuePair> requestParameters)
Loads the page using the given request method from the passed URL and stores it internally.void
run()
The run method must restore the state in case we constructed another action in between to prevalidate conditions.void
setLightWeightPage(LightWeightPage page)
Sets the given light-weight page object to be the result of this action.-
Methods inherited from class com.xceptance.xlt.api.actions.AbstractWebAction
addResponseProcessor, closeWebClient, createWebRequestSettings, getWebClient
-
Methods inherited from class com.xceptance.xlt.api.actions.AbstractAction
execute, executeThinkTime, getThinkTime, getThinkTimeDeviation, getTimerName, postValidate, preValidate, preValidateSafe, setThinkTime, setThinkTime, setThinkTimeDeviation, setThinkTimeDeviation, setTimerName
-
-
-
-
Constructor Detail
-
AbstractLightWeightPageAction
protected AbstractLightWeightPageAction(AbstractWebAction previousAction, java.lang.String timerName)
Creates a new AbstractLightWeightPageAction 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
-
AbstractLightWeightPageAction
protected AbstractLightWeightPageAction(java.lang.String timerName)
Creates a new AbstractLightWeightPageAction 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
-
getPreviousAction
public AbstractLightWeightPageAction getPreviousAction()
Returns the action that was passed as the previous action to the constructor. Allows to access data collected during the previous action.- Overrides:
getPreviousAction
in classAbstractWebAction
- Returns:
- the previous action (may be null)
-
getLightWeightPage
public LightWeightPage getLightWeightPage()
Returns the light-weight page generated by this action.- Returns:
- the page
-
getContent
public java.lang.String getContent()
Returns the unparsed content of the web page loaded by this action.- Returns:
- the content of the loaded page as string
-
getHttpResponseCode
public int getHttpResponseCode()
Returns the response code of the last loaded page.- Returns:
- the HTTP response code
-
getURL
public java.net.URL getURL()
Returns the URL that was used to load the page. Subsequent actions may use this value to create new URLs based on this URL.- Returns:
- the URL
-
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 classAbstractWebAction
- Throws:
java.lang.Throwable
- if an error occurred while running the action
-
setLightWeightPage
public void setLightWeightPage(LightWeightPage page)
Sets the given light-weight page object to be the result of this action. Typically, the light-weight page is generated by one of theloadPage()
methods and need not be set explicitly.- Parameters:
page
- the page to set
-
loadPage
protected void loadPage(java.net.URL url) throws java.lang.Exception
Loads the page using HTTP GET from the passed URL and stores it internally. The URL is stored for further reference.- Parameters:
url
- the target URL- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPage
protected void loadPage(java.lang.String urlAsString) throws java.lang.Exception
Creates an URL from the passed string, loads the page using HTTP GET and stores it internally. The URL is stored for further reference.- Parameters:
urlAsString
- an URL as string- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPage
protected void loadPage(java.net.URL url, HttpMethod method, java.util.List<NameValuePair> requestParameters) throws java.lang.Exception
Loads the page using the given request method from the passed URL and stores it internally. The specified request parameters are added either to the request body if the request method isHttpMethod.POST
or appended to the query string of the target URL for any other request method.- Parameters:
url
- the target URLmethod
- the HTTP request method to be usedrequestParameters
- the list of custom parameters to add- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
-