This is a nice packaging for the various information returned from taking a
sample of an entry.
addAssertionResult
public void addAssertionResult(AssertionResult assertResult)
addSubResult
public void addSubResult(SampleResult subResult)
configure
public void configure(Configuration info)
createTestSample
public static SampleResult createTestSample(long elapsed)
Create a sample with a specific elapsed time for test purposes, but don't
allow the times to be changed later
elapsed
- -
desired elapsed time
createTestSample
public static SampleResult createTestSample(long start,
long end)
Create a sample with specific start and end times for test purposes, but
don't allow the times to be changed later
(used by StatVisualizerModel.Test)
start
- start timeend
- end time
currentTimeInMs
public static long currentTimeInMs()
getAllThreads
public int getAllThreads()
getAssertionResults
public AssertionResult[] getAssertionResults()
Gets the assertion results associated with this sample.
- an array containing the assertion results for this sample.
Returns empty array if there are no assertion results.
getBytes
public int getBytes()
return the bytes returned by the response.
getContentType
public String getContentType()
- the full content type - e.g. text/html [;charset=utf-8 ]
getDataEncoding
public String getDataEncoding()
use getDataEncodingWithDefault() or getDataEncodingNoDefault() as needed.
Returns the dataEncoding or the default if no dataEncoding was provided
getDataEncodingNoDefault
public String getDataEncodingNoDefault()
Returns the dataEncoding. May be null or the empty String.
- the value of the dataEncoding
getDataEncodingWithDefault
public String getDataEncodingWithDefault()
Returns the dataEncoding or the default if no dataEncoding was provided
- the value of the dataEncoding or DEFAULT_ENCODING
getDataType
public String getDataType()
getEndTime
public long getEndTime()
getErrorCount
public int getErrorCount()
Returns the count of errors.
- 0 - or 1 if the sample failed
getGroupThreads
public int getGroupThreads()
getIdleTime
public long getIdleTime()
getLatency
public long getLatency()
getMediaType
public String getMediaType()
Get the media type from the Content Type
- the media type - e.g. text/html (without charset, if any)
getRequestHeaders
public String getRequestHeaders()
getResponseCode
public String getResponseCode()
getResponseData
public byte[] getResponseData()
Gets the responseData attribute of the SampleResult object.
Note that some samplers may not store all the data, in which case
getResponseData().length will be incorrect.
Instead, always use
getBytes()
to obtain the sample result byte count.
- the responseData value (cannot be null)
getResponseDataAsString
public String getResponseDataAsString()
Gets the responseData of the SampleResult object as a String
- the responseData value as a String, converted according to the encoding
getResponseHeaders
public String getResponseHeaders()
getResponseMessage
public String getResponseMessage()
getResultFileName
public String getResultFileName()
getSampleCount
public int getSampleCount()
return the sample count. by default, the value is 1.
getSampleLabel
public String getSampleLabel()
getSampleLabel
public String getSampleLabel(boolean includeGroup)
Get the sample label for use in summary reports etc.
includeGroup
- whether to include the thread group name
getSamplerData
public String getSamplerData()
getStartTime
public long getStartTime()
getSubResults
public SampleResult[] getSubResults()
Gets the subresults associated with this sample.
- an array containing the subresults for this sample. Returns an
empty array if there are no subresults.
getThreadName
public String getThreadName()
getTime
public long getTime()
Get the time it took this sample to occur.
- elapsed time in milliseonds
getTimeStamp
public long getTimeStamp()
Get the sample timestamp, which may be either the start time or the end time.
- timeStamp in milliseconds
getURL
public URL getURL()
getUrlAsString
public String getUrlAsString()
Get a String representation of the URL (if defined).
- ExternalForm of URL, or empty string if url is null
isMonitor
public boolean isMonitor()
If the sampler is a monitor, method will return true.
- true if the sampler is a monitor
isResponseCodeOK
public boolean isResponseCodeOK()
isStampedAtStart
public boolean isStampedAtStart()
isStopTest
public boolean isStopTest()
isStopTestNow
public boolean isStopTestNow()
- whether to stop the test now
isStopThread
public boolean isStopThread()
- whether to stop this thread
isSuccessful
public boolean isSuccessful()
latencyEnd
public void latencyEnd()
Set the time to the first response
markFile
public boolean markFile(String filename)
Set the "marked" flag to show that the result has been written to the file.
- true if the result was previously marked
sampleEnd
public void sampleEnd()
Record the end time of a sample and calculate the elapsed time
samplePause
public void samplePause()
Pause a sample
sampleResume
public void sampleResume()
Resume a sample
sampleStart
public void sampleStart()
Record the start time of a sample
setAllThreads
public void setAllThreads(int n)
setBytes
public void setBytes(int length)
In the event the sampler does want to pass back the actual contents, we
still want to calculate the throughput. The bytes is the bytes of the
response data.
setContentType
public void setContentType(String string)
Stores the content-type string, e.g. "text/xml; charset=utf-8"
setDataEncoding
public void setDataEncoding(String dataEncoding)
Sets the dataEncoding.
dataEncoding
- the dataEncoding to set, e.g. ISO-8895-1, UTF-8
setDataType
public void setDataType(String dataType)
setEncodingAndType
public void setEncodingAndType(String ct)
Extract and save the DataEncoding and DataType from the parameter provided.
Does not save the full content Type.
ct
- - content type (may be null)
setEndTime
protected void setEndTime(long end)
setErrorCount
public void setErrorCount(int i)
setGroupThreads
public void setGroupThreads(int n)
setLatency
public void setLatency(long latency)
This is only intended for use by SampleResultConverter!
latency
- The latency to set.
setMonitor
public void setMonitor(boolean monitor)
When a Sampler is working as a monitor
setParent
public void setParent(SampleResult parent)
parent
- The parent to set.
setRequestHeaders
public void setRequestHeaders(String string)
string
- -
request headers
setResponseCode
public void setResponseCode(String code)
setResponseCodeOK
public void setResponseCodeOK()
Set response code to OK, i.e. "200"
setResponseData
public void setResponseData(String response)
- only intended for use from BeanShell code
Sets the responseData attribute of the SampleResult object.
Should only be called after setting the dataEncoding (if necessary)
response
- the new responseData value (String)
setResponseData
public void setResponseData(byte[] response)
Sets the responseData attribute of the SampleResult object.
If the parameter is null, then the responseData is set to an empty byte array.
This ensures that getResponseData() can never be null.
response
- the new responseData value
setResponseHeaders
public void setResponseHeaders(String string)
string
- -
response headers
setResponseMessage
public void setResponseMessage(String msg)
setResponseMessageOK
public void setResponseMessageOK()
setResultFileName
public void setResultFileName(String resultFileName)
setSampleCount
public void setSampleCount(int count)
For the JMS sampler, it can perform multiple samples for greater degree
of accuracy.
setSampleLabel
public void setSampleLabel(String label)
setSamplerData
public void setSamplerData(String s)
setSaveConfig
public void setSaveConfig(SampleSaveConfiguration propertiesToSave)
propertiesToSave
- The propertiesToSave to set.
setStampAndTime
public void setStampAndTime(long stamp,
long elapsed)
setStartTime
protected final void setStartTime(long start)
setStopTest
public void setStopTest(boolean b)
setStopTestNow
public void setStopTestNow(boolean b)
setStopThread
public void setStopThread(boolean b)
setSuccessful
public void setSuccessful(boolean success)
Sets the successful attribute of the SampleResult object.
success
- the new successful value
setThreadName
public void setThreadName(String threadName)
setTime
public void setTime(long elapsed)
use sampleStart() and sampleEnd() instead
Method to set the elapsed time for a sample. Retained for backward
compatibility with 3rd party add-ons.
It is assumed that the method is only called at the end of a sample
and that timeStamps are end-times
Also used by SampleResultConverter when creating results from files.
Must not be used in conjunction with sampleStart()/End()
elapsed
- time in milliseconds
setTimeStamp
public void setTimeStamp(long timeStamp)
This is only intended for use by SampleResultConverter!
timeStamp
- The timeStamp to set.
setURL
public void setURL(URL location)
storeSubResult
public void storeSubResult(SampleResult subResult)
Add a subresult read from a results file.
As for addSubResult(), except that the fields don't need to be accumulated
toString
public String toString()
Returns the display name.
- display name of this sample result