use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class TestHTTPSamplers method testParseArguments2.
// Parse arguments all at once
@Test
public void testParseArguments2() {
HTTPSamplerBase sampler = new HTTPNullSampler();
Arguments args;
Argument arg;
args = sampler.getArguments();
assertEquals(0, args.getArgumentCount());
assertEquals(0, sampler.getHTTPFileCount());
sampler.parseArguments("&name1&name2=&name3=value3");
args = sampler.getArguments();
assertEquals(3, args.getArgumentCount());
assertEquals(0, sampler.getHTTPFileCount());
arg = args.getArgument(0);
assertEquals("name1", arg.getName());
assertEquals("", arg.getMetaData());
assertEquals("", arg.getValue());
assertEquals(0, sampler.getHTTPFileCount());
arg = args.getArgument(1);
assertEquals("name2", arg.getName());
assertEquals("=", arg.getMetaData());
assertEquals("", arg.getValue());
assertEquals(0, sampler.getHTTPFileCount());
arg = args.getArgument(2);
assertEquals("name3", arg.getName());
assertEquals("=", arg.getMetaData());
assertEquals("value3", arg.getValue());
assertEquals(0, sampler.getHTTPFileCount());
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class JavaSampler method sample.
/**
* Performs a test sample.
*
* The <code>sample()</code> method retrieves the reference to the Java
* client and calls its <code>runTest()</code> method.
*
* @see JavaSamplerClient#runTest(JavaSamplerContext)
*
* @param entry
* the Entry for this sample
* @return test SampleResult
*/
@Override
public SampleResult sample(Entry entry) {
Arguments args = getArguments();
// Allow Sampler access
args.addArgument(TestElement.NAME, getName());
// to test element name
context = new JavaSamplerContext(args);
if (javaClient == null) {
if (log.isDebugEnabled()) {
log.debug("{}\tCreating Java Client", whoAmI());
}
javaClient = createJavaClient();
javaClient.setupTest(context);
}
SampleResult result = javaClient.runTest(context);
// Only set the default label if it has not been set
if (result != null && result.getSampleLabel().length() == 0) {
result.setSampleLabel(getName());
}
return result;
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class SleepTest method 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.
*
* @return a specification of the parameters used by this test which should
* be listed in the GUI, or null if no parameters should be listed.
*/
@Override
public Arguments getDefaultParameters() {
Arguments params = new Arguments();
params.addArgument("SleepTime", String.valueOf(DEFAULT_SLEEP_TIME));
params.addArgument("SleepMask", "0x" + Long.toHexString(DEFAULT_SLEEP_MASK).toUpperCase(java.util.Locale.ENGLISH));
return params;
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class JavaTest method 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.
*
* @return a specification of the parameters used by this test which should
* be listed in the GUI, or null if no parameters should be listed.
*/
@Override
public Arguments getDefaultParameters() {
Arguments params = new Arguments();
params.addArgument(SLEEP_NAME, String.valueOf(DEFAULT_SLEEP_TIME));
params.addArgument(MASK_NAME, DEFAULT_MASK_STRING);
params.addArgument(LABEL_NAME, "");
params.addArgument(RESPONSE_CODE_NAME, RESPONSE_CODE_DEFAULT);
params.addArgument(RESPONSE_MESSAGE_NAME, RESPONSE_MESSAGE_DEFAULT);
params.addArgument(SUCCESS_NAME, SUCCESS_DEFAULT);
params.addArgument(SAMPLER_DATA_NAME, SAMPLER_DATA_DEFAULT);
params.addArgument(RESULT_DATA_NAME, SAMPLER_DATA_DEFAULT);
return params;
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class TestURLRewritingModifier method testGrabSessionIdURLinJSON.
@Test
public void testGrabSessionIdURLinJSON() throws Exception {
String html = "<a href=\"#\" onclick=\"$(\'frame\').src=\'/index?param1=bla&sessionid=xyzxyzxyz\\'";
response = new SampleResult();
response.setResponseData(html, null);
mod.setArgumentName("sessionid");
HTTPSamplerBase sampler = createSampler();
sampler.addArgument("sessionid", "xyzxyzxyz");
context.setCurrentSampler(sampler);
context.setPreviousResult(response);
mod.process();
Arguments args = sampler.getArguments();
assertEquals("xyzxyzxyz", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
}
Aggregations