I have to develop program that uses a custom method in Jmeter with java. And I would like to export a jar deployed to Jmeter's ext category. The code below supplies fixed parameters to Jmeter but how can I make these parameters dynamic?
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;
public class DoLoginSign extends AbstractJavaSamplerClient {
....
public Arguments getDefaultParameters() {
Arguments params = new Arguments();
params.addArgument("method", "dhnew.User.Login");
params.addArgument("language", "EN");
params.addArgument("timestamp", "2012-02-24 13:34:23");
params.addArgument("currency", "USD");
params.addArgument("is_hd", "0");
params.addArgument("sign_method", "md5");
params.addArgument("app_key", "kkk");
params.addArgument("cty", "US");
params.addArgument("format", "JSON");
params.addArgument("v", "1.1");
params.addArgument("uname", "angel_hanxd@eee.com");
params.addArgument("pwd", "9A90E4LMMMMMMMMMMM");
return params;
}
....
}
it can supply fixed param like show below
But it is too awful, and it takes a lot work to update the code. If there is a new API that has different params I have to develop new code to fit it even though they have the same function... only the params are different. Is there some method to use the Jmeter's [add] icon to generate parameters dynamically and transfer to my custom java project?