1
votes

I am a newbie to JMeter. I would like to know about how to use Java in Jmeter.

Description: We are trying to parameterize few inputs like user name, date of birth, telephone numbers etc in the request XML of a WebService(SOAP) Request for load performance testing. These values are randomly generated from a Java program. We need to pick these values from the Java program & insert in the request XML through parameterization.

I need to know how to achieve this in JMeter by using any Function helpers or any scripting?

Things I have tried : I am using Jmeter 2.8 version. I have tried CSV Data Set Config, User Defined Variables for parameterizing the XML & it works fine. But these are some static data which are stored in an excel sheet or pre-defined.

I would like to know how to parameterize the request XML, with the values from the Java program that are randomly generated. It would be really helpful if you can provide any sample examples of achieving this.

Thanks in advance

1

1 Answers

0
votes

There are several options on how you can get things done:

  1. Easiest one: JMeter OS Process Sampler. Just invoke your Java application as many times as required, fetch store output data to variable via Beanshell or Regular Expression Extractor post-processor.
  2. Harder one: if your random logic is simple enough you can replicate it inside JMeter using Beanshell, BSF or JSR233 Pre Processor (you'll need to write some code in bsf, jexl, beanshell or java)
  3. Hardest one (but the most optimal from performance perspective: if your Java has some public exported functions which can be called to get random values you can drop the .jar to /lib/ext folder of your JMeter installation, restart JMeter and whether call required methods from Beanshell or write i.e. custom Java Request or even a Sampler (see SleepTest java request sampler source code for example)