Method from org.apache.jmeter.samplers.SampleResult Detail: |
public void addAssertionResult(AssertionResult assertResult) {
if (assertionResults == null) {
assertionResults = new ArrayList();
}
assertionResults.add(assertResult);
}
|
public void addSubResult(SampleResult subResult) {
String tn = getThreadName();
if (tn.length()==0) {
tn=Thread.currentThread().getName();//TODO do this more efficiently
this.setThreadName(tn);
}
subResult.setThreadName(tn);
if (subResults == null) {
subResults = new ArrayList();
}
subResults.add(subResult);
// Extend the time to the end of the added sample
setEndTime(Math.max(getEndTime(), subResult.getEndTime()));
// Include the byte count for the added sample
setBytes(getBytes() + subResult.getBytes());
subResult.setParent(this);
}
|
public void configure(Configuration info) {
time = info.getAttributeAsLong(TOTAL_TIME, 0L);
}
|
public static SampleResult createTestSample(long elapsed) {
long now = currentTimeInMs();
return createTestSample(now, now + elapsed);
}
Create a sample with a specific elapsed time for test purposes, but don't
allow the times to be changed later |
public static SampleResult createTestSample(long start,
long end) {
SampleResult res = new SampleResult();
res.setStartTime(start);
res.setEndTime(end);
return res;
}
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) |
public static long currentTimeInMs() {
if (haveNanoTime()) {
long elapsedInMs = sampleNsClockInMs() - referenceTimeNsClock;
return referenceTimeMsClock + elapsedInMs;
} else {
return System.currentTimeMillis();
}
}
|
public int getAllThreads() {
return allThreads;
}
|
public AssertionResult[] getAssertionResults() {
if (assertionResults == null) {
return EMPTY_AR;
}
return (AssertionResult[]) assertionResults.toArray(new AssertionResult[0]);
}
Gets the assertion results associated with this sample. |
public int getBytes() {
return bytes == 0 ? responseData.length : bytes;
}
return the bytes returned by the response. |
public String getContentType() {
return contentType;
}
|
public String getDataEncoding() {
if (dataEncoding != null) {
return dataEncoding;
}
return DEFAULT_ENCODING;
} Deprecated! use - getDataEncodingWithDefault() or getDataEncodingNoDefault() as needed.
Returns the dataEncoding or the default if no dataEncoding was provided |
public String getDataEncodingNoDefault() {
return dataEncoding;
}
Returns the dataEncoding. May be null or the empty String. |
public String getDataEncodingWithDefault() {
if (dataEncoding != null && dataEncoding.length() > 0) {
return dataEncoding;
}
return DEFAULT_ENCODING;
}
Returns the dataEncoding or the default if no dataEncoding was provided |
public String getDataType() {
return dataType;
}
|
public long getEndTime() {
return endTime;
}
|
public int getErrorCount() {
return success ? 0 : 1;
}
Returns the count of errors. |
public int getGroupThreads() {
return groupThreads;
}
|
public long getIdleTime() {
return idleTime;
}
|
public long getLatency() {
return latency;
}
|
public String getMediaType() {
return JOrphanUtils.trim(contentType," ;").toLowerCase(java.util.Locale.ENGLISH);
}
Get the media type from the Content Type |
public SampleResult getParent() {
return parent;
}
|
public String getRequestHeaders() {
return requestHeaders;
}
|
public String getResponseCode() {
return responseCode;
}
|
public byte[] getResponseData() {
return responseData;
}
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.
|
public String getResponseDataAsString() {
try {
return new String(responseData,getDataEncodingWithDefault());
} catch (UnsupportedEncodingException e) {
log.warn("Using platform default as "+getDataEncodingWithDefault()+" caused "+e);
return new String(responseData);
}
}
Gets the responseData of the SampleResult object as a String |
public String getResponseHeaders() {
return responseHeaders;
}
|
public String getResponseMessage() {
return responseMessage;
}
|
public String getResultFileName() {
return resultFileName;
}
|
public int getSampleCount() {
return sampleCount;
}
return the sample count. by default, the value is 1. |
public String getSampleLabel() {
return label;
}
|
public String getSampleLabel(boolean includeGroup) {
if (includeGroup) {
StringBuffer sb = new StringBuffer(threadName.substring(0,threadName.lastIndexOf(" "))); //$NON-NLS-1$
return sb.append(":").append(label).toString(); //$NON-NLS-1$
}
return label;
}
Get the sample label for use in summary reports etc. |
public String getSamplerData() {
return samplerData;
}
|
public SampleSaveConfiguration getSaveConfig() {
return saveConfig;
}
|
public long getStartTime() {
return startTime;
}
|
public SampleResult[] getSubResults() {
if (subResults == null) {
return EMPTY_SR;
}
return (SampleResult[]) subResults.toArray(new SampleResult[0]);
}
Gets the subresults associated with this sample. |
public String getThreadName() {
return threadName;
}
|
public long getTime() {
return time;
}
Get the time it took this sample to occur. |
public long getTimeStamp() {
return timeStamp;
}
Get the sample timestamp, which may be either the start time or the end time. |
public URL getURL() {
return location;
}
|
public String getUrlAsString() {
return location == null ? "" : location.toExternalForm();
}
Get a String representation of the URL (if defined). |
public boolean isMonitor() {
return isMonitor;
}
If the sampler is a monitor, method will return true. |
public boolean isResponseCodeOK() {
return responseCode.equals(OK);
}
|
public boolean isStampedAtStart() {
return startTimeStamp;
}
|
public boolean isStopTest() {
return stopTest;
}
|
public boolean isStopTestNow() {
return stopTestNow;
}
|
public boolean isStopThread() {
return stopThread;
}
|
public boolean isSuccessful() {
return success;
}
|
public void latencyEnd() {
latency = currentTimeInMs() - startTime - idleTime;
}
Set the time to the first response |
public synchronized boolean markFile(String filename) {
return !files.add(filename);
}
Set the "marked" flag to show that the result has been written to the file. |
public void sampleEnd() {
if (endTime == 0) {
setEndTime(currentTimeInMs());
} else {
log.error("sampleEnd called twice", new Throwable("Invalid call sequence"));
}
}
Record the end time of a sample and calculate the elapsed time |
public void samplePause() {
if (pauseTime != 0) {
log.error("samplePause called twice", new Throwable("Invalid call sequence"));
}
pauseTime = currentTimeInMs();
}
|
public void sampleResume() {
if (pauseTime == 0) {
log.error("sampleResume without samplePause", new Throwable("Invalid call sequence"));
}
idleTime += currentTimeInMs() - pauseTime;
pauseTime = 0;
}
|
public void sampleStart() {
if (startTime == 0) {
setStartTime(currentTimeInMs());
} else {
log.error("sampleStart called twice", new Throwable("Invalid call sequence"));
}
}
Record the start time of a sample |
public void setAllThreads(int n) {
this.allThreads = n;
}
|
public void setBytes(int length) {
bytes = 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. |
public void setContentType(String string) {
contentType = string;
}
Stores the content-type string, e.g. "text/xml; charset=utf-8" |
public void setDataEncoding(String dataEncoding) {
this.dataEncoding = dataEncoding;
}
|
public void setDataType(String dataType) {
this.dataType = dataType;
}
|
public void setEncodingAndType(String ct) {
if (ct != null) {
// Extract charset and store as DataEncoding
// N.B. The meta tag:
// < META http-equiv="content-type" content="text/html; charset=foobar" >
// is now processed by HTTPSampleResult#getDataEncodingWithDefault
final String CS_PFX = "charset="; // $NON-NLS-1$
int cset = ct.toLowerCase(java.util.Locale.ENGLISH).indexOf(CS_PFX);
if (cset >= 0) {
// TODO - assumes charset is not followed by anything else
String charSet = ct.substring(cset + CS_PFX.length());
// Check for quoted string
if (charSet.startsWith("\"")){ // $NON-NLS-1$
setDataEncoding(charSet.substring(1, charSet.length()-1)); // remove quotes
} else {
setDataEncoding(charSet);
}
}
if (isBinaryType(ct)) {
setDataType(BINARY);
} else {
setDataType(TEXT);
}
}
}
Extract and save the DataEncoding and DataType from the parameter provided.
Does not save the full content Type. |
protected void setEndTime(long end) {
endTime = end;
if (!startTimeStamp) {
timeStamp = endTime;
}
if (startTime == 0) {
log.error("setEndTime must be called after setStartTime", new Throwable("Invalid call sequence"));
// TODO should this throw an error?
} else {
time = endTime - startTime - idleTime;
}
}
|
public void setErrorCount(int i) {
// for reading from CSV files
// ignored currently
}
|
public void setGroupThreads(int n) {
this.groupThreads = n;
}
|
public void setLatency(long latency) {
this.latency = latency;
}
This is only intended for use by SampleResultConverter! |
public void setMonitor(boolean monitor) {
isMonitor = monitor;
}
When a Sampler is working as a monitor |
public void setParent(SampleResult parent) {
this.parent = parent;
}
|
public void setRequestHeaders(String string) {
requestHeaders = string;
}
|
public void setResponseCode(String code) {
responseCode = code;
}
|
public void setResponseCodeOK() {
responseCode=OK;
}
Set response code to OK, i.e. "200" |
public void setResponseData(byte[] response) {
responseData = response == null ? EMPTY_BA : 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. |
public void setResponseData(String response) {
try {
responseData = response.getBytes(getDataEncodingWithDefault());
} catch (UnsupportedEncodingException e) {
log.warn("Could not convert string, using default encoding. "+e.getLocalizedMessage());
responseData = response.getBytes();
}
} Deprecated! - - 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) |
public void setResponseHeaders(String string) {
responseHeaders = string;
}
|
public void setResponseMessage(String msg) {
responseMessage = msg;
}
|
public void setResponseMessageOK() {
responseMessage = "OK"; // $NON-NLS-1$
}
|
public void setResultFileName(String resultFileName) {
this.resultFileName = resultFileName;
}
|
public void setSampleCount(int count) {
sampleCount = count;
}
For the JMS sampler, it can perform multiple samples for greater degree
of accuracy. |
public void setSampleLabel(String label) {
this.label = label;
}
|
public void setSamplerData(String s) {
samplerData = s;
}
|
public void setSaveConfig(SampleSaveConfiguration propertiesToSave) {
this.saveConfig = propertiesToSave;
}
|
public void setStampAndTime(long stamp,
long elapsed) {
if (startTime != 0 || endTime != 0){
throw new RuntimeException("Calling setStampAndTime() after start/end times have been set");
}
stampAndTime(stamp, elapsed);
}
|
protected final void setStartTime(long start) {
startTime = start;
if (startTimeStamp) {
timeStamp = startTime;
}
}
|
public void setStopTest(boolean b) {
stopTest = b;
}
|
public void setStopTestNow(boolean b) {
stopTestNow = b;
}
|
public void setStopThread(boolean b) {
stopThread = b;
}
|
public void setSuccessful(boolean success) {
this.success = success;
}
Sets the successful attribute of the SampleResult object. |
public void setThreadName(String threadName) {
this.threadName = threadName;
}
|
public void setTime(long elapsed) {
if (startTime != 0 || endTime != 0){
throw new RuntimeException("Calling setTime() after start/end times have been set");
}
long now = currentTimeInMs();
setTimes(now - elapsed, now);
} Deprecated! 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() |
public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
}
This is only intended for use by SampleResultConverter! |
public void setURL(URL location) {
this.location = location;
}
|
public void storeSubResult(SampleResult subResult) {
if (subResults == null) {
subResults = new ArrayList();
}
subResults.add(subResult);
subResult.setParent(this);
}
Add a subresult read from a results file.
As for addSubResult(), except that the fields don't need to be accumulated |
public String toString() {
return getSampleLabel();
}
Returns the display name. |