JMeter: Generates a value for the custom header with a Java class

advertisements

i try to test the performance for our api which has a request-limiter (100requets in 100sec otherwise the ip is blocked). You can avoid this with a custom header. The value for this header is generate by a java class.

With jruby i can use "require" and "import" too use the class.

How can i do this for JMeter?

Additional infos: the header value is dynamic -> for each request it has to be generated. To call HttpPwd.genPwd() two *.jar files are needed


This is how to proceed :

  • Put the 2 Jars in jmeter/lib folder

  • Put groovy-all.jar in jmeter/lib

  • Use a JSR223 Preprocessor + Groovy

  • Put in the Preprocessor the following code:

import xxxxxx; // where xxxx is the full name of the HttpPwd class

vars.put("header", HttpPwd.genPwd());

  • On your request add a HeaderManager as a child and in its content put:

HeaderName (I don't know what it is) : ${header}