Skip to main content

JMX Include

Jmx include let you include JMX fragment in your code. This can help for Component who are not yet available in JMC.

Depend on the node type you want to include use the following Class.

TypeClasschildren types
Thread GroupThreadGroupJmxIncludeWrapperControllers/Samplers
ControllersControllerJmxIncludeWrapperControllers/Samplers
SamplersSamplerJmxIncludeWrapperSamplers
Configuration ElementsConfigElementJmxIncludeWrapper-
Pre-ProcessorsPreProcessorJmxIncludeWrapper-
Post-ProcessorsPostProcessorJmxIncludeWrapper-
TimersTimerJmxIncludeWrapper-
AssertionsAssertionJmxIncludeWrapper-
ListenersListenerJmxIncludeWrapper-
Extend Wrapper

when you extend from a Wrapper class you have to annotated class with '@SuperBuilder(setterPrefix = "with", toBuilder = true)' . Full package is lombok.experimental.SuperBuilder

Methods#

Important Method to be used with JMX include are :

  1. withPath : give the resource path of JMX file.
  2. withParams : Input Map for parametrized file.

JMX File#

To have the JMX file you can save any node in Jmeter using the menu "save as Test Fragment".

Parameterized file.#

You can replace any text in JMX fragment to be replaced dynamically by code. JMC parameter have the following format ${jmc.paramname}: EX : Chose parameter name : for example "displayJMeterProperties", in JMX file replace content by ${jmc.displayJMeterProperties}

Ex:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.4.1">
<hashTree>
<TestFragmentController guiclass="TestFragmentControllerGui" testclass="TestFragmentController" testname="Test Fragment" enabled="false"/>
<hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
<boolProp name="displayJMeterProperties">${jmc.displayJMeterProperties}</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>

Input parameters can be provided using withParams method, or with @JmcParam annotation when using subClass.

Two way are available to use JMX include.#

Using extends#

Extends from the Class of your type and override method getDefaultPath to return the resource path of JMX file.

Ex :

@SuperBuilder(setterPrefix = "with", toBuilder = true)
public class DebugSamplerJmxIncludeWrapperTesting extends SamplerJmxIncludeWrapper {
private static final String PARENT_PATH = "org/anasoid/jmc/core/wrapper/jmeter/jmc/generic";
void DebugSamplerJmxIncludeWrapperTesting(boolean displayJMeterProperties){
this.displayJMeterProperties=displayJMeterProperties;
}
@JmcParam("displayJMeterProperties")
private static final Boolean displayJMeterProperties = false;
@Override
protected String getDefaultPath() {
return "org/myproject/jmx/include/debugsampler.jmx";
}
}

Using Direct Class#

To use direct Class you can use the class of your type and give the path of JMX file.

TestPlanWrapper testPlanWrapper =
TestPlanWrapper.builder()
.addThread(
ThreadGroupWrapper.builder()
.addSampler(
SamplerJmxIncludeWrapper.builder()
.withPath("org/myproject/jmx/include/debugsampler.jmx")
.withParams(Map.of("displayJMeterProperties", "true"))
.build())
.build())
.build();