0
votes

Jmeter Developer. I have already composed a .jmx using Java code by calling Jmeter's backend API. Now, I need to add Request Defaults Componet into my .jmx. However, I can not find the right API call on Java doc of Jmeter.

Where is the HTTP Request Defaults being defined in Java Doc and How can I add them?

newSampler.setProperty(TestElement.GUI_CLASS, HttpTestSampleGui.class.getName());

Something like above that create a http request sampler

2

2 Answers

0
votes

The relevant class is ConfigTestElement which can be initialized as follows:

ConfigTestElement httpRequestDefaults = new ConfigTestElement();
httpRequestDefaults.setName("HTTP Request Defaults");
httpRequestDefaults.setProperty(new TestElementProperty("HTTPsampler.Arguments", new HTTPArgumentsPanel().createTestElement()));
httpRequestDefaults.setProperty("HTTPSampler.domain", "hostname or IP address of your server");
httpRequestDefaults.setProperty("HTTPSampler.port", "1234");
httpRequestDefaults.setProperty("HTTPSampler.protocol", "https");
httpRequestDefaults.setProperty("HTTPSampler.contentEncoding", "UTF-8");
httpRequestDefaults.setProperty("HTTPSampler.path", "/");
httpRequestDefaults.setProperty("HTTPSampler.concurrentPool", "6");
httpRequestDefaults.setProperty("HTTPSampler.connect_timeout", "10000");
httpRequestDefaults.setProperty("HTTPSampler.response_timeout", "10000");
httpRequestDefaults.setProperty(TestElement.TEST_CLASS, ConfigTestElement.class.getName());
httpRequestDefaults.setProperty(TestElement.GUI_CLASS, HttpDefaultsGui.class.getName());

Replace the properties with the values of your choice including eventual default parameters.

References:

0
votes

You can find its hierarchy as follow:

Class HttpDefaultsGui
 java.lang.Object
  java.awt.Component
   java.awt.Container
    javax.swing.JComponent
     javax.swing.JPanel
      org.apache.jmeter.gui.AbstractJMeterGuiComponent
       org.apache.jmeter.config.gui.AbstractConfigGui
        org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui

Note: Please visit the link to find more information. It was tricky to find it thou. [HttpDefaultsGui_Class][1]

[1]: https://jmeter.apache.org/api/org/apache/jmeter/protocol/http/config/gui/HttpDefaultsGui.html