Class JavaTest
-
- All Implemented Interfaces:
-
java.io.Serializable
,org.apache.jmeter.protocol.java.sampler.JavaSamplerClient
,org.apache.jmeter.samplers.Interruptible
@AutoService(value = JavaSamplerClient.class) public class JavaTest extends AbstractJavaSamplerClient implements Serializable, Interruptible
The
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:
Thus, the Sleep_Mask provides a way to add a random component to the sleep time.totalSleepTime = Sleep_Time + (System.currentTimeMillis() % Sleep_Mask)
The sampler is able to define the precise values of:
The elapsed time and end-time cannot be directly controlled.- responseCode - responseMessage - Label - success/fail status
Note: this class was derived from SleepTest.
-
-
Field Summary
Fields Modifier and Type Field Description public final static long
DEFAULT_SLEEP_TIME
public final static long
DEFAULT_SLEEP_MASK
-
Constructor Summary
Constructors Constructor Description JavaTest()
Default constructor for JavaTest
.
-
Method Summary
Modifier and Type Method Description void
setupTest(JavaSamplerContext context)
Do any initialization required by this client. Arguments
getDefaultParameters()
Provide a list of parameters which this test supports. SampleResult
runTest(JavaSamplerContext context)
Perform a single sample. boolean
interrupt()
-
-
Method Detail
-
setupTest
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.
- 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.
-
runTest
SampleResult runTest(JavaSamplerContext context)
Perform a single sample. In this case, this method will simply sleep for some amount of time. This method returns a
SampleResult
object.
The following fields are set from the user-defined parameters, if supplied: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)
-samplerData - responseData
- Parameters:
context
- the context to run with.
-
interrupt
boolean interrupt()
-
-
-
-