Apache JMeter | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient
org.apache.jmeter.protocol.java.test.JavaTest
JavaTest
class is a simple sampler which is intended for
use when developing test plans. The sampler generates results internally, so
does not need access to any external resources such as web, ftp or LDAP
servers. In addition, because the exact values of most of the SampleResult
can be directly set, it is possible to easily test most Assertions that use
the sample results.
During each sample, this client will sleep for some amount of time. The
amount of time to sleep is determined from the two parameters Sleep_Time and
Sleep_Mask using the formula:
totalSleepTime = Sleep_Time + (System.currentTimeMillis() % Sleep_Mask)Thus, the Sleep_Mask provides a way to add a random component to the sleep time. The sampler is able to define the precise values of:
- responseCode - responseMessage - Label - success/fail statusThe elapsed time and end-time cannot be directly controlled. Note: this class was derived from
SleepTest
.
Field Summary | |
static long |
|
static long |
|
Constructor Summary | |
|
Method Summary | |
Arguments |
|
SampleResult |
|
void |
|
void |
|
Methods inherited from class org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient | |
getDefaultParameters , getLogger , setupTest , teardownTest |
public static final long DEFAULT_SLEEP_MASK
The default value of the SleepMask parameter.
- Field Value:
- 255L
public static final long DEFAULT_SLEEP_TIME
The default value of the SleepTime parameter, in milliseconds.
- Field Value:
- 100L
public JavaTest()
Default constructor forJavaTest
. The Java Sampler uses the default constructor to instantiate an instance of the client class.
public Arguments getDefaultParameters()
Provide a list of parameters which this test supports. Any parameter names and associated values returned by this method will appear in the GUI by default so the user doesn't have to remember the exact names. The user can add other parameters which are not listed here. If this method returns null then no parameters will be listed. If the value for some parameter is null then that parameter will be listed in the GUI with an empty value.
- Specified by:
- getDefaultParameters in interface JavaSamplerClient
- Overrides:
- getDefaultParameters in interface AbstractJavaSamplerClient
- Returns:
- a specification of the parameters used by this test which should be listed in the GUI, or null if no parameters should be listed.
public SampleResult runTest(JavaSamplerContext context)
Perform a single sample.
In this case, this method will simply sleep for some amount of time. This method returns aSampleResult
object.The following fields are always set: - responseCode (default "") - responseMessage (default "") - label (set from LABEL_NAME parameter if it exists, else element name) - success (default true)The following fields are set from the user-defined parameters, if supplied:-samplerData - responseData
- Specified by:
- runTest in interface JavaSamplerClient
- Parameters:
context
- the context to run with. This provides access to initialization parameters.
- Returns:
- a SampleResult giving the results of this sample.
- See Also:
SampleResult.sampleStart()
,SampleResult.sampleEnd()
,SampleResult.setSuccessful(boolean)
,SampleResult.setSampleLabel(String)
,SampleResult.setResponseCode(String)
,SampleResult.setResponseMessage(String)
,org.apache.jmeter.samplers.SampleResult.setResponseData(byte [])
,SampleResult.setDataType(String)
public void setupTest(JavaSamplerContext context)
Do any initialization required by this client. There is none, as it is done in runTest() in order to be able to vary the data for each sample.
- Specified by:
- setupTest in interface JavaSamplerClient
- Overrides:
- setupTest in interface AbstractJavaSamplerClient
- Parameters:
context
- the context to run with. This provides access to initialization parameters.
public void teardownTest(JavaSamplerContext context)
Do any clean-up required by this test. In this case no clean-up is necessary, but some messages are logged for debugging purposes.
- Specified by:
- teardownTest in interface JavaSamplerClient
- Overrides:
- teardownTest in interface AbstractJavaSamplerClient
- Parameters:
context
- the context to run with. This provides access to initialization parameters.