This article describes calling your own Java Toolkit in JMeter, not directly inheriting the Java sample request interface provided by JMeter.
Tools/Materials
Method/Step
- When using JMeter as an HTTP request (or other type), it is sometimes necessary to do a specific processing of the requested data (or the data in response), such as encryption and decryption.
- We can use Java to write some tool classes, use the BeanShell provided by JMeter to call our tool class to process the data, and then make the related request.
- First write a tool class in Eclipse, I wrote a tool class Getstringwithlbrb.java that intercepts strings based on the left and right boundaries, "select" All of your class files that you write, "click" Select Export, "Export" jar package (casually named, Remember the package path for this class in eclipse)
- Then put the exported jar package into the \apache-jmeter-2.12\lib\ext directory, create a project in JMeter, add an HTTP request, and in this request we add a pre-BeanShell.
- Importing our Jar packages in BeanShell (the path that we see in Eclipse), the two methods in BeanShell are the most commonly used: Vars.get (String paramstr), Vars.put (string key , String value), the previous one obtains the value of the variable from JMeter, and the latter is the data stored in the JMeter variable.
- Show me Abc123def the string 123 and then save it to jmeter so I can use ${paramname in jmeter to get my processed value.
- So for the request before the encryption, the request to decrypt the situation, we can write our own toolkit for related data processing
How to invoke the Java toolkit that you wrote in JMeter