3

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 enter image description here

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?

Archmede
  • 1,592
  • 2
  • 20
  • 37
kaku21
  • 129
  • 1
  • 1
  • 11
  • You may keep all argument like key value pair and read from db or some file. As i understand correctly you load all argument while login to app. – newuserua_ext Aug 07 '15 at 11:55

0 Answers0