public class SampleResult extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, Searchable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BINARY
Data type value ("bin") indicating that the response data is binary.
|
protected static java.lang.String |
DEFAULT_ENCODING
The default encoding to be used to decode the responseData byte array.
|
static java.lang.String |
DEFAULT_HTTP_ENCODING
The default encoding to be used if not overridden.
|
static java.lang.String |
TEXT
Data type value ("text") indicating that the response data is text.
|
Modifier | Constructor and Description |
---|---|
|
SampleResult() |
protected |
SampleResult(long elapsed,
boolean atend)
Create a sample with a specific elapsed time but don't allow the times to
be changed later
(only used by HTTPSampleResult)
|
|
SampleResult(long stamp,
long elapsed)
Allow users to create a sample with specific timestamp and elapsed times
for cloning purposes, but don't allow the times to be changed later
Currently used by CSVSaveService and
StatisticalSampleResult
|
|
SampleResult(SampleResult res)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAssertionResult(AssertionResult assertResult) |
void |
addRawSubResult(SampleResult subResult)
Add a subresult to the collection without updating any parent fields.
|
void |
addSubResult(SampleResult subResult)
Add a subresult and adjust the parent byte count and end-time.
|
void |
addSubResult(SampleResult subResult,
boolean renameSubResults)
Add a subresult and adjust the parent byte count and end-time.
|
void |
cleanAfterSample()
Clean up cached data
|
java.lang.Object |
clone() |
void |
connectEnd()
Set the time to the end of connecting
|
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
|
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)
|
long |
currentTimeInMillis()
Helper method to get 1 ms resolution timing.
|
int |
getAllThreads() |
AssertionResult[] |
getAssertionResults()
Gets the assertion results associated with this sample.
|
int |
getBodySize()
Deprecated.
replaced by getBodySizeAsLong()
|
long |
getBodySizeAsLong() |
int |
getBytes()
Deprecated.
use getBytesAsLong
|
long |
getBytesAsLong()
return the bytes returned by the response.
|
long |
getConnectTime() |
java.lang.String |
getContentType() |
java.lang.String |
getDataEncodingNoDefault()
Returns the dataEncoding.
|
java.lang.String |
getDataEncodingWithDefault()
Returns the dataEncoding or the default if no dataEncoding was provided.
|
protected java.lang.String |
getDataEncodingWithDefault(java.lang.String defaultEncoding)
Returns the dataEncoding or the default if no dataEncoding was provided.
|
java.lang.String |
getDataType()
Returns the data type of the sample.
|
long |
getEndTime() |
int |
getErrorCount()
Returns the count of errors.
|
java.lang.String |
getFirstAssertionFailureMessage() |
int |
getGroupThreads() |
int |
getHeadersSize()
Get the headers size in bytes
|
long |
getIdleTime() |
long |
getLatency() |
java.lang.String |
getMediaType()
Get the media type from the Content Type
|
SampleResult |
getParent() |
java.lang.String |
getRequestHeaders() |
java.lang.String |
getResponseCode() |
byte[] |
getResponseData()
Gets the responseData attribute of the SampleResult object.
|
java.lang.String |
getResponseDataAsString()
Gets the responseData of the SampleResult object as a String
|
java.lang.String |
getResponseHeaders() |
java.lang.String |
getResponseMessage() |
java.lang.String |
getResultFileName() |
int |
getSampleCount()
return the sample count. by default, the value is 1.
|
java.lang.String |
getSampleLabel() |
java.lang.String |
getSampleLabel(boolean includeGroup)
Get the sample label for use in summary reports etc.
|
java.lang.String |
getSamplerData() |
SampleSaveConfiguration |
getSaveConfig() |
java.util.List<java.lang.String> |
getSearchableTokens()
Get a list of all tokens that should be visible to searching
|
long |
getSentBytes() |
long |
getStartTime() |
SampleResult[] |
getSubResults()
Gets the subresults associated with this sample.
|
JMeterContext.TestLogicalAction |
getTestLogicalAction() |
java.lang.String |
getThreadName() |
long |
getTime()
Get the time it took this sample to occur.
|
long |
getTimeStamp()
Get the sample timestamp, which may be either the start time or the end time.
|
java.net.URL |
getURL() |
java.lang.String |
getUrlAsString()
Get a String representation of the URL (if defined).
|
boolean |
isIgnore() |
boolean |
isMonitor()
Deprecated.
since 3.2 always return false
|
protected boolean |
isRenameSampleLabel()
see https://bz.apache.org/bugzilla/show_bug.cgi?
|
boolean |
isResponseCodeOK() |
boolean |
isStampedAtStart() |
boolean |
isStartNextThreadLoop()
Deprecated.
|
boolean |
isStopTest() |
boolean |
isStopTestNow() |
boolean |
isStopThread() |
boolean |
isSuccessful() |
void |
latencyEnd()
Set the time to the first response
|
boolean |
markFile(java.lang.String filename)
Set the "marked" flag to show that the result has been written to the file.
|
void |
removeAssertionResults()
Allow custom SampleSenders to drop unwanted assertionResults
|
void |
removeSubResults()
Allow custom SampleSenders to drop unwanted subResults
|
void |
sampleEnd()
Record the end time of a sample and calculate the elapsed time
|
void |
samplePause()
Pause a sample
|
void |
sampleResume()
Resume a sample
|
void |
sampleStart()
Record the start time of a sample
|
void |
setAllThreads(int n) |
void |
setBodySize(int bodySize)
Deprecated.
use setBodySize(long)
|
void |
setBodySize(long bodySize) |
void |
setBytes(int length)
Deprecated.
use setBytes(long)
|
void |
setBytes(long length)
In the event the sampler does want to pass back the actual contents, we
still want to calculate the throughput.
|
void |
setConnectTime(long time)
This is only intended for use by SampleResultConverter!
|
void |
setContentType(java.lang.String string)
Stores the content-type string, e.g.
|
void |
setDataEncoding(java.lang.String dataEncoding)
Sets the dataEncoding.
|
void |
setDataType(java.lang.String dataType)
Sets the data type of the sample.
|
void |
setEncodingAndType(java.lang.String ct)
Extract and save the DataEncoding and DataType from the parameter provided.
|
void |
setEndTime(long end) |
void |
setErrorCount(int i) |
void |
setGroupThreads(int n) |
void |
setHeadersSize(int size)
Set the headers size in bytes
|
void |
setIdleTime(long idle)
Set idle time pause.
|
void |
setIgnore()
Call this method to tell JMeter to ignore this SampleResult by Listeners
|
void |
setLatency(long latency)
This is only intended for use by SampleResultConverter!
|
void |
setMonitor(boolean monitor)
Deprecated.
since 3.2 NOOP
|
void |
setParent(SampleResult parent) |
void |
setRequestHeaders(java.lang.String string) |
void |
setResponseCode(java.lang.String code) |
void |
setResponseCodeOK()
Set response code to OK, i.e. "200"
|
void |
setResponseData(byte[] response)
Sets the responseData attribute of the SampleResult object.
|
void |
setResponseData(java.lang.String response)
Deprecated.
- only intended for use from BeanShell code
|
void |
setResponseData(java.lang.String response,
java.lang.String encoding)
Sets the encoding and responseData attributes of the SampleResult object.
|
void |
setResponseHeaders(java.lang.String string) |
void |
setResponseMessage(java.lang.String msg) |
void |
setResponseMessageOK() |
void |
setResponseOK()
Set result statuses OK - shorthand method to set:
ResponseCode
ResponseMessage
Successful status
|
void |
setResultFileName(java.lang.String resultFileName) |
void |
setSampleCount(int count)
The statistical sample sender aggregates several samples to save on
transmission costs.
|
void |
setSampleLabel(java.lang.String label) |
void |
setSamplerData(java.lang.String s) |
void |
setSaveConfig(SampleSaveConfiguration propertiesToSave) |
void |
setSentBytes(long sentBytesCount) |
void |
setStampAndTime(long stamp,
long elapsed)
For use by SaveService only.
|
void |
setStartNextThreadLoop(boolean startNextThreadLoop)
Deprecated.
use SampleResult#setTestLogicalAction(TestLogicalAction)
|
protected void |
setStartTime(long start) |
void |
setStopTest(boolean b) |
void |
setStopTestNow(boolean b) |
void |
setStopThread(boolean b) |
void |
setSuccessful(boolean success)
Sets the successful attribute of the SampleResult object.
|
void |
setTestLogicalAction(JMeterContext.TestLogicalAction testLogicalAction) |
void |
setThreadName(java.lang.String threadName) |
void |
setTimeStamp(long timeStamp)
This is only intended for use by SampleResultConverter!
|
void |
setURL(java.net.URL location) |
void |
storeSubResult(SampleResult subResult)
Add a subresult read from a results file.
|
java.lang.String |
toString()
Returns the display name.
|
public static final java.lang.String DEFAULT_HTTP_ENCODING
protected static final java.lang.String DEFAULT_ENCODING
public static final java.lang.String TEXT
public static final java.lang.String BINARY
public SampleResult()
public SampleResult(SampleResult res)
res
- existing sample resultprotected SampleResult(long elapsed, boolean atend)
elapsed
- timeatend
- create the sample finishing now, else starting nowpublic SampleResult(long stamp, long elapsed)
stamp
- this may be a start time or an end time (both in
milliseconds)elapsed
- time in millisecondspublic void setSaveConfig(SampleSaveConfiguration propertiesToSave)
propertiesToSave
- The propertiesToSave to set.public SampleSaveConfiguration getSaveConfig()
public boolean isStampedAtStart()
public static SampleResult createTestSample(long start, long end)
start
- start time in milliseconds since unix epochend
- end time in milliseconds since unix epochpublic static SampleResult createTestSample(long elapsed)
elapsed
- - desired elapsed time in millisecondselapsed
milliseconds laterpublic long currentTimeInMillis()
java.lang.RuntimeException
- when useNanoTime
is true
but
nanoTimeOffset
is not setpublic void setStampAndTime(long stamp, long elapsed)
stamp
- this may be a start time or an end time (both in milliseconds)elapsed
- time in millisecondsjava.lang.RuntimeException
- when startTime
or endTime
has been
set alreadypublic boolean markFile(java.lang.String filename)
filename
- the name of the filetrue
if the result was previously markedpublic java.lang.String getResponseCode()
public void setResponseCodeOK()
public void setResponseCode(java.lang.String code)
public boolean isResponseCodeOK()
public java.lang.String getResponseMessage()
public void setResponseMessage(java.lang.String msg)
public void setResponseMessageOK()
public void setResponseOK()
public java.lang.String getThreadName()
public void setThreadName(java.lang.String threadName)
public long getTimeStamp()
getStartTime()
,
getEndTime()
public java.lang.String getSampleLabel()
public java.lang.String getSampleLabel(boolean includeGroup)
includeGroup
- whether to include the thread group namepublic void setSampleLabel(java.lang.String label)
public void addAssertionResult(AssertionResult assertResult)
public AssertionResult[] getAssertionResults()
public void addSubResult(SampleResult subResult)
subResult
- the SampleResult
to be addedprotected final boolean isRenameSampleLabel()
public void addSubResult(SampleResult subResult, boolean renameSubResults)
subResult
- the SampleResult
to be addedrenameSubResults
- boolean do we rename subResults based on positionpublic void addRawSubResult(SampleResult subResult)
subResult
- the SampleResult
to be addedpublic void storeSubResult(SampleResult subResult)
As for addSubResult(SampleResult)
, except that the fields don't need to be
accumulated
subResult
- the SampleResult
to be addedpublic SampleResult[] getSubResults()
public void setResponseData(byte[] response)
response
- the new responseData value@Deprecated public void setResponseData(java.lang.String response)
response
- the new responseData value (String)public void setResponseData(java.lang.String response, java.lang.String encoding)
response
- the new responseData value (String)encoding
- the encoding to set and then use (if null, use platform default)public byte[] getResponseData()
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.
public java.lang.String getResponseDataAsString()
public void setSamplerData(java.lang.String s)
public java.lang.String getSamplerData()
public long getTime()
public boolean isSuccessful()
public void setDataType(java.lang.String dataType)
public java.lang.String getDataType()
public void setEncodingAndType(java.lang.String ct)
ct
- - content type (may be null)which should be used to save the full content-type string
public void setSuccessful(boolean success)
success
- the new successful valuepublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getDataEncodingWithDefault()
protected java.lang.String getDataEncodingWithDefault(java.lang.String defaultEncoding)
defaultEncoding
- the default to be appliedpublic java.lang.String getDataEncodingNoDefault()
public void setDataEncoding(java.lang.String dataEncoding)
dataEncoding
- the dataEncoding to set, e.g. ISO-8895-1, UTF-8public boolean isStopTest()
public boolean isStopTestNow()
public boolean isStopThread()
public void setStopTest(boolean b)
public void setStopTestNow(boolean b)
public void setStopThread(boolean b)
public java.lang.String getRequestHeaders()
public java.lang.String getResponseHeaders()
public void setRequestHeaders(java.lang.String string)
string
- -
request headerspublic void setResponseHeaders(java.lang.String string)
string
- -
response headerspublic java.lang.String getContentType()
public java.lang.String getMediaType()
public void setContentType(java.lang.String string)
text/xml; charset=utf-8
string
- the content-type to be setwhich can be used to extract the charset.
public long getIdleTime()
public long getEndTime()
public long getStartTime()
protected final void setStartTime(long start)
public void setEndTime(long end)
public void setIdleTime(long idle)
idle
- longpublic void sampleStart()
public void sampleEnd()
public void samplePause()
public void sampleResume()
@Deprecated public void setMonitor(boolean monitor)
monitor
- flag whether this sampler is working as a monitor@Deprecated public boolean isMonitor()
public void setSampleCount(int count)
count
- number of samples represented by this instancepublic int getSampleCount()
public int getErrorCount()
public void setErrorCount(int i)
public void setBytes(long length)
length
- the number of bytes of the response data for this sample@Deprecated public void setBytes(int length)
length
- the number of bytes of the response data for this samplepublic void setSentBytes(long sentBytesCount)
sentBytesCount
- long sent bytespublic long getSentBytes()
@Deprecated public int getBytes()
public long getBytesAsLong()
public long getLatency()
public void latencyEnd()
public void setLatency(long latency)
latency
- The latency to set.public long getConnectTime()
public void connectEnd()
public void setConnectTime(long time)
time
- The connect time to set.public void setTimeStamp(long timeStamp)
timeStamp
- The timeStamp to set.public void setURL(java.net.URL location)
public java.net.URL getURL()
public java.lang.String getUrlAsString()
public SampleResult getParent()
public void setParent(SampleResult parent)
parent
- The parent to set.public java.lang.String getResultFileName()
public void setResultFileName(java.lang.String resultFileName)
public int getGroupThreads()
public void setGroupThreads(int n)
public int getAllThreads()
public void setAllThreads(int n)
public void removeAssertionResults()
public void removeSubResults()
public void setHeadersSize(int size)
size
- the number of bytes of the headerpublic int getHeadersSize()
@Deprecated public int getBodySize()
public long getBodySizeAsLong()
public void setBodySize(long bodySize)
bodySize
- the body size to set@Deprecated public void setBodySize(int bodySize)
bodySize
- the body size to set@Deprecated public boolean isStartNextThreadLoop()
getTestLogicalAction()
@Deprecated public void setStartNextThreadLoop(boolean startNextThreadLoop)
startNextThreadLoop
- the startNextLoop to setpublic void cleanAfterSample()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.util.List<java.lang.String> getSearchableTokens() throws java.lang.Exception
Searchable
getSearchableTokens
in interface Searchable
java.lang.Exception
- when something fails while getting the searchable tokenspublic boolean isIgnore()
public void setIgnore()
public java.lang.String getFirstAssertionFailureMessage()
public JMeterContext.TestLogicalAction getTestLogicalAction()
public void setTestLogicalAction(JMeterContext.TestLogicalAction testLogicalAction)
testLogicalAction
- the testLogicalAction to setCopyright © 1998-2019 Apache Software Foundation. All Rights Reserved.