Apache JMeter
2.0.1.20050615

org.apache.jmeter.samplers
Class SampleResult

java.lang.Object
  extended byorg.apache.jmeter.samplers.SampleResult
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
HTTPSampleResult

public class SampleResult
extends Object
implements Serializable

This is a nice packaging for the various information returned from taking a sample of an entry.

Version:
$Revision: 1.29.2.5 $ $Date: 2004/09/30 17:55:05 $
See Also:
Serialized Form

Nested Class Summary
static class SampleResult.Test
           
 
Field Summary
static String BINARY
          Data type value indicating that the response data is binary.
static String TEXT
          Data type value indicating that the response data is text.
 
Constructor Summary
  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 SaveService only
  SampleResult(SampleResult res)
          Construct a 'parent' result for an already-existing result, essentially cloning it
 
Method Summary
 void addAssertionResult(AssertionResult assertResult)
           
 void addSubResult(SampleResult subResult)
           
 void configure(org.apache.avalon.framework.configuration.Configuration info)
           
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)
 AssertionResult[] getAssertionResults()
          Gets the assertion results associated with this sample.
 String getContentType()
           
 String getDataEncoding()
          Returns the dataEncoding.
 String getDataType()
           
 long getEndTime()
           
 String getRequestHeaders()
           
 String getResponseCode()
           
 byte[] getResponseData()
          Gets the responseData attribute of the SampleResult object.
 String getResponseHeaders()
           
 String getResponseMessage()
           
 String getSampleLabel()
           
 String getSamplerData()
           
 long getStartTime()
           
 SampleResult[] getSubResults()
          Gets the subresults associated with this sample.
 String getThreadName()
           
 long getTime()
          Get the time it took this sample to occur.
 long getTimeStamp()
           
 URL getURL()
           
 boolean isMarked(String filename)
           
 boolean isMonitor()
          If the sampler is a monitor, method will return true.
 boolean isStopTest()
           
 boolean isStopThread()
           
 boolean isSuccessful()
           
 byte[] responseDataAsBA()
          Convenience method to get responseData as a non-null byte array
 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 setContentType(String string)
           
 void setDataEncoding(String dataEncoding)
          Sets the dataEncoding.
 void setDataType(String dataType)
           
 void setMarked(String filename)
           
 void setMonitor(boolean monitor)
          When a Sampler is working as a monitor
 void setRequestHeaders(String string)
           
 void setResponseCode(String code)
           
 void setResponseData(byte[] response)
          Sets the responseData attribute of the SampleResult object.
 void setResponseHeaders(String string)
           
 void setResponseMessage(String msg)
           
 void setSampleLabel(String label)
           
 void setSamplerData(String s)
           
protected  void setStartTime(long start)
           
 void setStopTest(boolean b)
           
 void setStopThread(boolean b)
           
 void setSuccessful(boolean success)
          Sets the successful attribute of the SampleResult object.
 void setThreadName(String threadName)
           
 void setTime(long elapsed)
          Deprecated. use sampleStart() and sampleEnd() instead
 void setURL(URL location)
           
 String toString()
          Returns the display name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TEXT

public static final String TEXT
Data type value indicating that the response data is text.

See Also:
getDataType(), setDataType(java.lang.String), Constant Field Values

BINARY

public static final String BINARY
Data type value indicating that the response data is binary.

See Also:
getDataType(), setDataType(java.lang.String), Constant Field Values
Constructor Detail

SampleResult

public SampleResult()

SampleResult

public SampleResult(SampleResult res)
Construct a 'parent' result for an already-existing result, essentially cloning it

Parameters:
res - existing sample result

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)

Parameters:
elapsed - time
atend - create the sample finishing now, else starting now

SampleResult

public 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 SaveService only

Parameters:
stamp - - this may be a start time or an end time
elapsed -
Method Detail

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)

Parameters:
start - start time
end - end time

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

Parameters:
elapsed - - desired elapsed time

setTime

public void setTime(long elapsed)
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 called at the end of a sample Must not be used in conjunction with sampleStart()/End()

Parameters:
elapsed - time in milliseconds

setMarked

public void setMarked(String filename)

isMarked

public boolean isMarked(String filename)

getResponseCode

public String getResponseCode()

setResponseCode

public void setResponseCode(String code)

getResponseMessage

public String getResponseMessage()

setResponseMessage

public void setResponseMessage(String msg)

getThreadName

public String getThreadName()

setThreadName

public void setThreadName(String threadName)

getTimeStamp

public long getTimeStamp()

getSampleLabel

public String getSampleLabel()

setSampleLabel

public void setSampleLabel(String label)

addAssertionResult

public void addAssertionResult(AssertionResult assertResult)

getAssertionResults

public AssertionResult[] getAssertionResults()
Gets the assertion results associated with this sample.

Returns:
an array containing the assertion results for this sample. Returns empty array if there are no assertion results.

addSubResult

public void addSubResult(SampleResult subResult)

getSubResults

public SampleResult[] getSubResults()
Gets the subresults associated with this sample.

Returns:
an array containing the subresults for this sample. Returns an empty array if there are no subresults.

configure

public void configure(org.apache.avalon.framework.configuration.Configuration info)

setResponseData

public void setResponseData(byte[] response)
Sets the responseData attribute of the SampleResult object.

Parameters:
response - the new responseData value

getResponseData

public byte[] getResponseData()
Gets the responseData attribute of the SampleResult object.

Returns:
the responseData value

responseDataAsBA

public byte[] responseDataAsBA()
Convenience method to get responseData as a non-null byte array

Returns:
the responseData. If responseData is null then an empty byte array is returned rather than null.

setSamplerData

public void setSamplerData(String s)

getSamplerData

public String getSamplerData()

getTime

public long getTime()
Get the time it took this sample to occur.

Returns:
elapsed time in milliseonds

isSuccessful

public boolean isSuccessful()

setDataType

public void setDataType(String dataType)

getDataType

public String getDataType()

setSuccessful

public void setSuccessful(boolean success)
Sets the successful attribute of the SampleResult object.

Parameters:
success - the new successful value

toString

public String toString()
Returns the display name.

Returns:
display name of this sample result

getDataEncoding

public String getDataEncoding()
Returns the dataEncoding.


setDataEncoding

public void setDataEncoding(String dataEncoding)
Sets the dataEncoding.

Parameters:
dataEncoding - the dataEncoding to set, e.g. ISO-8895-1, UTF-8

isStopTest

public boolean isStopTest()
Returns:
whether to stop the test

isStopThread

public boolean isStopThread()
Returns:
whether to stop this thread

setStopTest

public void setStopTest(boolean b)
Parameters:
b -

setStopThread

public void setStopThread(boolean b)
Parameters:
b -

getRequestHeaders

public String getRequestHeaders()
Returns:
the request headers

getResponseHeaders

public String getResponseHeaders()
Returns:
the response headers

setRequestHeaders

public void setRequestHeaders(String string)
Parameters:
string - - request headers

setResponseHeaders

public void setResponseHeaders(String string)
Parameters:
string - - response headers

getContentType

public String getContentType()
Returns:
the content type - e.g. text/html [;charset=utf-8 ]

setContentType

public void setContentType(String string)
Parameters:
string -

getEndTime

public long getEndTime()
Returns:
the end time

getStartTime

public long getStartTime()
Returns:
the start time

setStartTime

protected final void setStartTime(long start)

sampleStart

public void sampleStart()
Record the start time of a sample


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


setMonitor

public void setMonitor(boolean monitor)
When a Sampler is working as a monitor

Parameters:
monitor -

isMonitor

public boolean isMonitor()
If the sampler is a monitor, method will return true.

Returns:
true if the sampler is a monitor

setURL

public void setURL(URL location)

getURL

public URL getURL()

Apache JMeter
2.0.1.20050615

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