Class SleepTest
-
- All Implemented Interfaces:
-
java.io.Serializable,org.apache.jmeter.protocol.java.sampler.JavaSamplerClient,org.apache.jmeter.samplers.Interruptible
@AutoService(value = JavaSamplerClient.class) public class SleepTest extends AbstractJavaSamplerClient implements Serializable, Interruptible
The
SleepTestclass is a simple example class for a JMeter Java protocol client. The class implements theJavaSamplerClientinterface.During each sample, this client will sleep for some amount of time. The amount of time to sleep is determined from the two parameters SleepTime and SleepMask using the formula:
Thus, the SleepMask provides a way to add a random component to the sleep time.totalSleepTime = SleepTime + (System.currentTimeMillis() % SleepMask)
-
-
Constructor Summary
Constructors Constructor Description SleepTest()Default constructor for SleepTest.
-
Method Summary
Modifier and Type Method Description voidsetupTest(JavaSamplerContext context)Do any initialization required by this client. SampleResultrunTest(JavaSamplerContext context)Perform a single sample. ArgumentsgetDefaultParameters()Provide a list of parameters which this test supports. booleaninterrupt()-
-
Method Detail
-
setupTest
void setupTest(JavaSamplerContext context)
Do any initialization required by this client. In this case, initialization consists of getting the values of the SleepTime and SleepMask parameters. It is generally recommended to do any initialization such as getting parameter values in the setupTest method rather than the runTest method in order to add as little overhead as possible to the test.
- Parameters:
context- the context to run with.
-
runTest
SampleResult runTest(JavaSamplerContext context)
Perform a single sample. In this case, this method will simply sleep for some amount of time. Perform a single sample for each iteration. This method returns a
SampleResultobject.SampleResulthas many fields which can be used. At a minimum, the test should useSampleResult.sampleStartandSampleResult.sampleEndto set the time that the test required to execute. It is also a good idea to set the sampleLabel and the successful flag.- Parameters:
context- the context to run with.
-
getDefaultParameters
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.
-
interrupt
boolean interrupt()
-
-
-
-