public class SleepTest extends AbstractJavaSamplerClient implements Serializable, Interruptible
SleepTest
class is a simple example class for a JMeter
Java protocol client. The class implements the JavaSamplerClient
interface.
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:
totalSleepTime = SleepTime + (System.currentTimeMillis() % SleepMask)Thus, the SleepMask provides a way to add a random component to the sleep time.
Constructor and Description |
---|
SleepTest()
Default constructor for
SleepTest . |
Modifier and Type | Method and Description |
---|---|
Arguments |
getDefaultParameters()
Provide a list of parameters which this test supports.
|
boolean |
interrupt()
Interrupt the current operation if possible.
|
SampleResult |
runTest(JavaSamplerContext context)
Perform a single sample.
|
void |
setupTest(JavaSamplerContext context)
Do any initialization required by this client.
|
getLogger, getNewLogger, teardownTest
public SleepTest()
SleepTest
.
The Java Sampler uses the default constructor to instantiate an instance
of the client class.public void setupTest(JavaSamplerContext context)
setupTest
in interface JavaSamplerClient
setupTest
in class AbstractJavaSamplerClient
context
- the context to run with. This provides access to
initialization parameters.public SampleResult runTest(JavaSamplerContext context)
SampleResult
object.
SampleResult
has many fields which can be used. At a
minimum, the test should use SampleResult.sampleStart
and
SampleResult.sampleEnd
to set the time that the test
required to execute. It is also a good idea to set the sampleLabel and
the successful flag.runTest
in interface JavaSamplerClient
context
- the context to run with. This provides access to
initialization parameters.SampleResult.sampleStart()
,
SampleResult.sampleEnd()
,
SampleResult.setSuccessful(boolean)
,
SampleResult.setSampleLabel(String)
public Arguments getDefaultParameters()
getDefaultParameters
in interface JavaSamplerClient
getDefaultParameters
in class AbstractJavaSamplerClient
public boolean interrupt()
Interruptible
interrupt
in interface Interruptible
true
if there was an operation to interrupt.Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.