public class SampleResult extends Object implements Serializable, Cloneable, Searchable
Modifier and Type | Field and Description |
---|---|
static String |
BINARY
Data type value ("bin") indicating that the response data is binary.
|
protected static String |
DEFAULT_ENCODING
The default encoding to be used to decode the responseData byte array.
|
static String |
DEFAULT_HTTP_ENCODING
The default encoding to be used if not overridden.
|
static 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
|
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() |
String |
getContentType() |
String |
getDataEncodingNoDefault()
Returns the dataEncoding.
|
String |
getDataEncodingWithDefault()
Returns the dataEncoding or the default if no dataEncoding was provided.
|
protected String |
getDataEncodingWithDefault(String defaultEncoding)
Returns the dataEncoding or the default if no dataEncoding was provided.
|
String |
getDataType()
Returns the data type of the sample.
|
long |
getEndTime() |
int |
getErrorCount()
Returns the count of errors.
|
String |
getFirstAssertionFailureMessage() |
int |
getGroupThreads() |
int |
getHeadersSize()
Get the headers size in bytes
|
long |
getIdleTime() |
long |
getLatency() |
String |
getMediaType()
Get the media type from the Content Type
|
SampleResult |
getParent() |
String |
getRequestHeaders() |
String |
getResponseCode() |
byte[] |
getResponseData()
Gets the responseData attribute of the SampleResult object.
|
String |
getResponseDataAsString()
Gets the responseData of the SampleResult object as a String
|
String |
getResponseHeaders() |
String |
getResponseMessage() |
String |
getResultFileName() |
int |
getSampleCount()
return the sample count.
|
String |
getSampleLabel() |
String |
getSampleLabel(boolean includeGroup)
Get the sample label for use in summary reports etc.
|
String |
getSamplerData() |
SampleSaveConfiguration |
getSaveConfig() |
List<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() |
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.
|
URL |
getURL() |
String |
getUrlAsString()
Get a String representation of the URL (if defined).
|
static boolean |
isBinaryType(String ct) |
boolean |
isIgnore() |
boolean |
isMonitor()
Deprecated.
since 3.2 always return false
|
static boolean |
isRenameSampleLabel()
see https://bz.apache.org/bugzilla/show_bug.cgi?id=63055
|
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(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(String string)
Stores the content-type string, e.g.
|
void |
setDataEncoding(String dataEncoding)
Sets the dataEncoding.
|
void |
setDataType(String dataType)
Sets the data type of the sample.
|
void |
setEncodingAndType(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(String string) |
void |
setResponseCode(String code) |
void |
setResponseCodeOK()
Set response code to OK, i.e.
|
void |
setResponseData(byte[] response)
Sets the responseData attribute of the SampleResult object.
|
void |
setResponseData(String response)
Deprecated.
- only intended for use from BeanShell code
|
void |
setResponseData(String response,
String encoding)
Sets the encoding and responseData attributes of the SampleResult object.
|
void |
setResponseHeaders(String string) |
void |
setResponseMessage(String msg) |
void |
setResponseMessageOK() |
void |
setResponseOK()
Set result statuses OK - shorthand method to set:
ResponseCode
ResponseMessage
Successful status
|
void |
setResultFileName(String resultFileName) |
void |
setSampleCount(int count)
The statistical sample sender aggregates several samples to save on
transmission costs.
|
void |
setSampleLabel(String label) |
void |
setSamplerData(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(String threadName) |
void |
setTimeStamp(long timeStamp)
This is only intended for use by SampleResultConverter!
|
void |
setURL(URL location) |
void |
storeSubResult(SampleResult subResult)
Add a subresult read from a results file.
|
String |
toString()
Returns the display name.
|
public static final String DEFAULT_HTTP_ENCODING
protected static final String DEFAULT_ENCODING
public static final String TEXT
public static final 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()
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 millisecondsRuntimeException
- when startTime
or endTime
has been
set alreadypublic boolean markFile(String filename)
filename
- the name of the filetrue
if the result was previously markedpublic String getResponseCode()
public void setResponseCodeOK()
public void setResponseCode(String code)
public boolean isResponseCodeOK()
public String getResponseMessage()
public void setResponseMessage(String msg)
public void setResponseMessageOK()
public void setResponseOK()
public String getThreadName()
public void setThreadName(String threadName)
public long getTimeStamp()
getStartTime()
,
getEndTime()
public String getSampleLabel()
public String getSampleLabel(boolean includeGroup)
includeGroup
- whether to include the thread group namepublic void setSampleLabel(String label)
public void addAssertionResult(AssertionResult assertResult)
public AssertionResult[] getAssertionResults()
public void addSubResult(SampleResult subResult)
subResult
- the SampleResult
to be addedpublic static 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(String response)
response
- the new responseData value (String)public void setResponseData(String response, 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 String getResponseDataAsString()
public void setSamplerData(String s)
public String getSamplerData()
public long getTime()
public boolean isSuccessful()
public void setDataType(String dataType)
public String getDataType()
public void setEncodingAndType(String ct)
ct
- - content type (may be null)which should be used to save the full content-type string
public static boolean isBinaryType(String ct)
public void setSuccessful(boolean success)
success
- the new successful valuepublic String toString()
public String getDataEncodingWithDefault()
protected String getDataEncodingWithDefault(String defaultEncoding)
defaultEncoding
- the default to be appliedpublic String getDataEncodingNoDefault()
public void setDataEncoding(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 String getRequestHeaders()
public String getResponseHeaders()
public void setRequestHeaders(String string)
string
- -
request headerspublic void setResponseHeaders(String string)
string
- -
response headerspublic String getContentType()
public String getMediaType()
public void setContentType(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(URL location)
public URL getURL()
public String getUrlAsString()
public SampleResult getParent()
public void setParent(SampleResult parent)
parent
- The parent to set.public String getResultFileName()
public void setResultFileName(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 List<String> getSearchableTokens() throws Exception
Searchable
getSearchableTokens
in interface Searchable
Exception
- when something fails while getting the searchable tokenspublic boolean isIgnore()
public void setIgnore()
public 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.