Apache JMeter
2.0.1.20050615

org.apache.jmeter.protocol.http.sampler
Class HTTPSamplerBase

java.lang.Object
  extended byorg.apache.jmeter.testelement.AbstractTestElement
      extended byorg.apache.jmeter.samplers.AbstractSampler
          extended byorg.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
All Implemented Interfaces:
Cloneable, Sampler, Serializable, TestElement, TestListener
Direct Known Subclasses:
HTTPSampler, HTTPSampler2

public abstract class HTTPSamplerBase
extends AbstractSampler
implements TestListener

Common constants and methods for HTTP samplers

Version:
$Revision: 1.1.2.7 $ Last updated $Date: 2004/11/07 02:59:52 $
See Also:
Serialized Form

Field Summary
static String ARGUMENTS
           
static String AUTH_MANAGER
           
static String AUTO_REDIRECTS
           
static String CONTENT_TYPE
           
static String COOKIE_MANAGER
           
static int DEFAULT_HTTP_PORT
           
static int DEFAULT_HTTPS_PORT
           
static String DEFAULT_PROTOCOL
           
static String DOMAIN
           
static String FILE_DATA
           
static String FILE_FIELD
           
static String FILE_MIMETYPE
           
static String FILE_NAME
           
static String FOLLOW_REDIRECTS
           
static String GET
           
static String HEADER_MANAGER
           
static String IMAGE_PARSER
           
protected static int MAX_FRAME_DEPTH
           
protected static int MAX_REDIRECTS
           
static String METHOD
           
static String MIMETYPE
           
static String MONITOR
           
static String MULTIPART_FORM
           
protected static String NON_HTTP_RESPONSE_CODE
           
protected static String NON_HTTP_RESPONSE_MESSAGE
           
static String NORMAL_FORM
           
static String PATH
           
static String PORT
           
static String POST
           
static String PROTOCOL
           
static int UNSPECIFIED_PORT
          A number to indicate that the port has not been set.
static String URL
           
static String USE_KEEPALIVE
           
 
Fields inherited from interface org.apache.jmeter.testelement.TestElement
ENABLED, GUI_CLASS, NAME, TEST_CLASS
 
Constructor Summary
HTTPSamplerBase()
           
 
Method Summary
 void addArgument(String name, String value)
           
 void addArgument(String name, String value, String metadata)
           
 void addEncodedArgument(String name, String value, String metaData)
           
 void addTestElement(TestElement el)
           
 Object clone()
           
protected  HTTPSampleResult downloadPageResources(HTTPSampleResult res, boolean createContainerResult, int frameDepth)
          Download the resources of an HTML page.
protected  String encodeSpaces(String path)
           
protected  HTTPSampleResult errorResult(Throwable e, String data, long time)
          Obtain a result that will help inform the user that an error has occured during sampling, and how long it took to detect the error.
 Arguments getArguments()
           
 AuthManager getAuthManager()
           
 CookieManager getCookieManager()
           
 String getDomain()
           
 String getFileField()
           
 String getFilename()
           
 boolean getFollowRedirects()
           
 HeaderManager getHeaderManager()
           
 String getMethod()
           
 String getMimetype()
           
 String getMonitor()
           
 String getPath()
           
 int getPort()
           
 String getProtocol()
           
 String getQueryString()
          Gets the QueryString attribute of the UrlConfig object.
 URL getUrl()
          Get the URL, built from its component parts.
 boolean getUseKeepAlive()
           
 boolean isImageParser()
           
 boolean isMonitor()
           
 void parseArguments(String queryString)
          This method allows a proxy server to send over the raw text from a browser's output stream to be parsed and stored correctly into the UrlConfig object.
 SampleResult sample()
          Perform a sample, and return the results
 SampleResult sample(Entry e)
          Do a sampling and return its results.
protected abstract  HTTPSampleResult sample(URL u, String s, boolean b, int i)
           
 void setArguments(Arguments value)
           
 void setAuthManager(AuthManager value)
           
 void setCookieManager(CookieManager value)
           
 void setDomain(String value)
           
 void setFileField(String value)
           
 void setFilename(String value)
           
 void setFollowRedirects(boolean value)
           
 void setHeaderManager(HeaderManager value)
           
 void setImageParser(boolean parseImages)
           
 void setMethod(String value)
           
 void setMimetype(String value)
           
 void setMonitor(String value)
           
 void setPath(String path)
          Sets the Path attribute of the UrlConfig object Also calls parseArguments to extract and store any query arguments
 void setPort(int value)
           
 void setProtocol(String value)
           
 void setUseKeepAlive(boolean value)
           
 void testEnded()
          Called once for all threads after the end of a test
 void testEnded(String host)
           
 void testIterationStart(LoopIterationEvent event)
          Each time through a Thread Group's test script, an iteration event is fired.
 void testStarted()
          Called just before the start of the test Note that not all the test variables will have been set up at this point.
 void testStarted(String host)
           
 String toString()
           
 
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
addProperty, canRemove, clear, clearTemporary, emptyTemporary, equals, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getThreadContext, getThreadName, isRunningVersion, isTemporary, logProperties, mergeIn, nextIsNull, propertyIterator, recoverRunningVersion, removeProperty, setName, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, threadFinished, threadStarted, traverse, traverseCollection, traverseMap, traverseProperty
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.jmeter.testelement.TestElement
canRemove, clear, getProperty, getPropertyAsBoolean, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getThreadContext, getThreadName, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removeProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, threadFinished, threadStarted, traverse
 

Field Detail

DEFAULT_HTTPS_PORT

public static final int DEFAULT_HTTPS_PORT
See Also:
Constant Field Values

DEFAULT_HTTP_PORT

public static final int DEFAULT_HTTP_PORT
See Also:
Constant Field Values

ARGUMENTS

public static final String ARGUMENTS
See Also:
Constant Field Values

AUTH_MANAGER

public static final String AUTH_MANAGER
See Also:
Constant Field Values

COOKIE_MANAGER

public static final String COOKIE_MANAGER
See Also:
Constant Field Values

HEADER_MANAGER

public static final String HEADER_MANAGER
See Also:
Constant Field Values

MIMETYPE

public static final String MIMETYPE
See Also:
Constant Field Values

DOMAIN

public static final String DOMAIN
See Also:
Constant Field Values

PORT

public static final String PORT
See Also:
Constant Field Values

METHOD

public static final String METHOD
See Also:
Constant Field Values

PATH

public static final String PATH
See Also:
Constant Field Values

FOLLOW_REDIRECTS

public static final String FOLLOW_REDIRECTS
See Also:
Constant Field Values

AUTO_REDIRECTS

public static final String AUTO_REDIRECTS
See Also:
Constant Field Values

PROTOCOL

public static final String PROTOCOL
See Also:
Constant Field Values

DEFAULT_PROTOCOL

public static final String DEFAULT_PROTOCOL
See Also:
Constant Field Values

URL

public static final String URL
See Also:
Constant Field Values

POST

public static final String POST
See Also:
Constant Field Values

GET

public static final String GET
See Also:
Constant Field Values

USE_KEEPALIVE

public static final String USE_KEEPALIVE
See Also:
Constant Field Values

FILE_NAME

public static final String FILE_NAME
See Also:
Constant Field Values

FILE_FIELD

public static final String FILE_FIELD
See Also:
Constant Field Values

FILE_DATA

public static final String FILE_DATA
See Also:
Constant Field Values

FILE_MIMETYPE

public static final String FILE_MIMETYPE
See Also:
Constant Field Values

CONTENT_TYPE

public static final String CONTENT_TYPE
See Also:
Constant Field Values

NORMAL_FORM

public static final String NORMAL_FORM
See Also:
Constant Field Values

MULTIPART_FORM

public static final String MULTIPART_FORM
See Also:
Constant Field Values

IMAGE_PARSER

public static final String IMAGE_PARSER
See Also:
Constant Field Values

MONITOR

public static final String MONITOR
See Also:
Constant Field Values

UNSPECIFIED_PORT

public static final int UNSPECIFIED_PORT
A number to indicate that the port has not been set.

See Also:
Constant Field Values

NON_HTTP_RESPONSE_CODE

protected static final String NON_HTTP_RESPONSE_CODE
See Also:
Constant Field Values

NON_HTTP_RESPONSE_MESSAGE

protected static final String NON_HTTP_RESPONSE_MESSAGE
See Also:
Constant Field Values

MAX_REDIRECTS

protected static final int MAX_REDIRECTS
See Also:
Constant Field Values

MAX_FRAME_DEPTH

protected static final int MAX_FRAME_DEPTH
See Also:
Constant Field Values
Constructor Detail

HTTPSamplerBase

public HTTPSamplerBase()
Method Detail

setFileField

public void setFileField(String value)

getFileField

public String getFileField()

setFilename

public void setFilename(String value)

getFilename

public String getFilename()

setProtocol

public void setProtocol(String value)

getProtocol

public String getProtocol()

setPath

public void setPath(String path)
Sets the Path attribute of the UrlConfig object Also calls parseArguments to extract and store any query arguments

Parameters:
path - The new Path value

getPath

public String getPath()

setFollowRedirects

public void setFollowRedirects(boolean value)

getFollowRedirects

public boolean getFollowRedirects()

setMethod

public void setMethod(String value)

getMethod

public String getMethod()

setUseKeepAlive

public void setUseKeepAlive(boolean value)

getUseKeepAlive

public boolean getUseKeepAlive()

setMonitor

public void setMonitor(String value)

getMonitor

public String getMonitor()

isMonitor

public boolean isMonitor()

addEncodedArgument

public void addEncodedArgument(String name,
                               String value,
                               String metaData)

addArgument

public void addArgument(String name,
                        String value)

addArgument

public void addArgument(String name,
                        String value,
                        String metadata)

addTestElement

public void addTestElement(TestElement el)
Specified by:
addTestElement in interface TestElement
Overrides:
addTestElement in class AbstractTestElement

setPort

public void setPort(int value)

getPort

public int getPort()

setDomain

public void setDomain(String value)

getDomain

public String getDomain()

setArguments

public void setArguments(Arguments value)

getArguments

public Arguments getArguments()

setAuthManager

public void setAuthManager(AuthManager value)

getAuthManager

public AuthManager getAuthManager()

setHeaderManager

public void setHeaderManager(HeaderManager value)

getHeaderManager

public HeaderManager getHeaderManager()

setCookieManager

public void setCookieManager(CookieManager value)

getCookieManager

public CookieManager getCookieManager()

setMimetype

public void setMimetype(String value)

getMimetype

public String getMimetype()

isImageParser

public boolean isImageParser()

setImageParser

public void setImageParser(boolean parseImages)

errorResult

protected HTTPSampleResult errorResult(Throwable e,
                                       String data,
                                       long time)
Obtain a result that will help inform the user that an error has occured during sampling, and how long it took to detect the error.

Parameters:
e - Exception representing the error.
data - a piece of data associated to the error (e.g. URL)
time - time spent detecting the error (0 for client-only issues)
Returns:
a sampling result useful to inform the user about the exception.

getUrl

public URL getUrl()
           throws MalformedURLException
Get the URL, built from its component parts.

Returns:
The URL to be requested by this sampler.
Throws:
MalformedURLException

getQueryString

public String getQueryString()
Gets the QueryString attribute of the UrlConfig object.

Returns:
the QueryString value

parseArguments

public void parseArguments(String queryString)
This method allows a proxy server to send over the raw text from a browser's output stream to be parsed and stored correctly into the UrlConfig object. For each name found, addEncodedArgument() is called

Parameters:
queryString - - the query string

toString

public String toString()

sample

public SampleResult sample(Entry e)
Do a sampling and return its results.

Specified by:
sample in interface Sampler
Parameters:
e - Entry to be sampled
Returns:
results of the sampling

sample

public SampleResult sample()
Perform a sample, and return the results

Returns:
results of the sampling

sample

protected abstract HTTPSampleResult sample(URL u,
                                           String s,
                                           boolean b,
                                           int i)

downloadPageResources

protected HTTPSampleResult downloadPageResources(HTTPSampleResult res,
                                                 boolean createContainerResult,
                                                 int frameDepth)
Download the resources of an HTML page.

If createContainerResult is true, the returned result will contain one subsample for each request issued, including the original one that was passed in. It will otherwise look exactly like that original one.

If createContainerResult is false, one subsample will be added to the provided result for each requests issued.

Parameters:
res - result of the initial request - must contain an HTML response
createContainerResult - whether to create a "container" or just use the provided res for that purpose
frameDepth - Depth of this target in the frame structure. Used only to prevent infinite recursion.
Returns:
"Container" result with one subsample per request issued

encodeSpaces

protected String encodeSpaces(String path)

testEnded

public void testEnded()
Description copied from interface: TestListener
Called once for all threads after the end of a test

Specified by:
testEnded in interface TestListener
See Also:
StandardJMeterEngine.stopTest()

testEnded

public void testEnded(String host)
Specified by:
testEnded in interface TestListener

testIterationStart

public void testIterationStart(LoopIterationEvent event)
Description copied from interface: TestListener
Each time through a Thread Group's test script, an iteration event is fired.

Specified by:
testIterationStart in interface TestListener
Parameters:
event -

testStarted

public void testStarted()
Description copied from interface: TestListener
Called just before the start of the test Note that not all the test variables will have been set up at this point.

Specified by:
testStarted in interface TestListener
See Also:
StandardJMeterEngine.run()

testStarted

public void testStarted(String host)
Specified by:
testStarted in interface TestListener

clone

public Object clone()
Specified by:
clone in interface TestElement
Overrides:
clone in class AbstractTestElement

Apache JMeter
2.0.1.20050615

Copyright © 1998-2005 Apache Software Foundation. All Rights Reserved.