jmeter-java-dsl
jmeter-java-dsl copied to clipboard
JMeter Function ${__base64Encode} Not Executing Correctly in JMeter DSL When Loading .jmx File
- Loading the .jmx file that was created previously by JMeter and run it using JMeterDSL.
- The .jmx file contains a request with the following JMeter function: ${__base64Encode(Username,)}.
what I Expected that the ${__base64Encode(Username,)} function should encode the Username value to Base64.
but the Actual Behavior when run the script was the ${__base64Encode(Username,)} function is treated as a plain string and does not perform the Base64 encoding.
also i have included the following dependencies in my project:
There is currently no support for usign jmeter-plugins-functions, and the problem is caused by jmeter configuration don't having such jar in the search path for libraries. You can use a groovy lambda instead of using such function like Username.bytes.encodeBase64().toString(). Another alternative might be adding the jar in the search path by extending EmbeddedJmeterEngine ovewritting run method to pass your own extended version of JmeterEnvironment which could overwrite updateSearchPath by doing something like:
private static class MyEnv extends JmeterEnvironment {
public MyEnv() throws IOException {
}
public void updateSearchPath(HashTree tree) {
super.updateSearchPath(tree);
Properties props = JMeterUtils.getJMeterProperties();
String searchPathsPropName = "search_paths";
String prevPath = props.getProperty(searchPathsPropName);
String functionJarPath = new File(Base64Encoder.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath()
props.setProperty(searchPathsPropName,prevPath + ";" + functionJarPath);
}
}
Another alternative might be to contribute some improvement to JMeter DSL general logic for solving the search path from a test plan so it not only includes test elements classes in the search but also function classes, but I guess this might be tricky. A simpler contribution could be to add a method to EmbeddedJmeterEngine (and in JmeterEnvironment) that allows to add a particular class (like the one of the function you mention) in the search path, so whenever someone wants, they can add new function classes to the search path, if they need to.
Hello, have you tried the previously mentioned workaround?
Yes , thanks
On Mon, 27 Jan 2025, 5:45 pm rabelenda, @.***> wrote:
Hello, have you tried the previously mentioned workaround?
— Reply to this email directly, view it on GitHub https://github.com/abstracta/jmeter-java-dsl/issues/290#issuecomment-2616114580, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFZ524CMGXRAFJ3CIF7ID32MZICDAVCNFSM6AAAAABUHB3NGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMJWGEYTINJYGA . You are receiving this because you authored the thread.Message ID: @.***>