JMeter5.4.1 source IDEA construction & secondary development (combat)
1. Download source code
Jmeter.apache.org/download_jm…
2. Import the IDEA
2.1 Set up the Gradle directory first
You are advised to set up Gradle user directory.
2.2 Importing the JMeter project
2.3 Setting up the Domestic Gradle source
Set the download source for Gradle
Speed direct take-off! 😂 [Obtain information]
Reload Gradle or reload the project.
Next is the patient waiting, good network speed, about 30-3h can be downloaded. [Obtain information]
2.4 perform runGui
After the overall project is built, the familiar JMeter can now be opened.
3. Add system functions
We got the source code for the secondary development of JMeter. My current requirement is to add custom system functions.
The whole process
-
System functions are under SRC /functions. We need to add system functions in it.
-
Apachejmeter_functions.jar = apachejmeter_functions.jar = apache-jmeter-5.2.1lib \ext
Combat: added custom UUID system functions
I would like to add a UUID system function that removes -. Create a new Java class in Java \org\apache\jmeter\functions
package org.apache.jmeter.functions; import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.UUID; import org.apache.jmeter.engine.util.CompoundVariable; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.samplers.Sampler; /** * Create a custom UUID that does not contain "-" ** Parameters: * - None ** Returns: * - A pseudo random UUID 4 * */ public class UuidCustomer extends AbstractFunction { private static final List<String> desc = new LinkedList<>(); Private static final String KEY = "__UUID2"; $non-nls-1 $public UuidCustomer() {} @override public String execute(SampleResult previousResult) Sampler currentSampler) throws InvalidVariableException { return UUID.randomUUID().toString().replace("-", ""); } @Override public void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { checkParameterCount(parameters, 0, 0); } @Override public String getReferenceKey() { return KEY; } @Override public List<String> getArgumentDesc() { return desc; }}Copy the code
Run the test
Click runGui to run the test.
Perfect success. Next it is packaged and replaced with the JMeter in use
The Jar package
After success, a JAR package will be created in [Get information].
Rename this package and replace it
Use the replacement JMeter to view
Perfect success! 🤙 🤙 🤙
System function inside the key explanation
Take DigestEncodeFunction for example. [Obtain information]
The level is limited, just take a look at the general implementation process, after understanding it, it is convenient for us to customize or modify
In the end, I wish you all success as soon as possible, get satisfactory offer, fast promotion and salary increase, and walk on the peak of life.
If you can, please give me a three support me??????[Obtain information]