Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly, you want to run an entire test plan programmatically from within a Java program. Personally, I find it easier to create a test plan .JMX file and run it in JMeter non-GUI mode :)</p> <p>Here is a simple Java example based on the controller and sampler used in the original question.</p> <pre><code>import org.apache.jmeter.control.LoopController; import org.apache.jmeter.engine.StandardJMeterEngine; import org.apache.jmeter.protocol.http.sampler.HTTPSampler; import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.TestPlan; import org.apache.jmeter.threads.SetupThreadGroup; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.collections.HashTree; public class JMeterTestFromCode { public static void main(String[] args){ // Engine StandardJMeterEngine jm = new StandardJMeterEngine(); // jmeter.properties JMeterUtils.loadJMeterProperties("c:/tmp/jmeter.properties"); HashTree hashTree = new HashTree(); // HTTP Sampler HTTPSampler httpSampler = new HTTPSampler(); httpSampler.setDomain("www.google.com"); httpSampler.setPort(80); httpSampler.setPath("/"); httpSampler.setMethod("GET"); // Loop Controller TestElement loopCtrl = new LoopController(); ((LoopController)loopCtrl).setLoops(1); ((LoopController)loopCtrl).addTestElement(httpSampler); ((LoopController)loopCtrl).setFirst(true); // Thread Group SetupThreadGroup threadGroup = new SetupThreadGroup(); threadGroup.setNumThreads(1); threadGroup.setRampUp(1); threadGroup.setSamplerController((LoopController)loopCtrl); // Test plan TestPlan testPlan = new TestPlan("MY TEST PLAN"); hashTree.add("testPlan", testPlan); hashTree.add("loopCtrl", loopCtrl); hashTree.add("threadGroup", threadGroup); hashTree.add("httpSampler", httpSampler); jm.configure(hashTree); jm.run(); } } </code></pre> <p><strong>Dependencies</strong></p> <p>These are the bare mininum JARs required based on JMeter 2.9 and the HTTPSampler used. Other samplers will most likely have different library JAR dependencies.</p> <ul> <li>ApacheJMeter_core.jar</li> <li>jorphan.jar</li> <li>avalon-framework-4.1.4.jar</li> <li>ApacheJMeter_http.jar</li> <li>commons-logging-1.1.1.jar</li> <li>logkit-2.0.jar</li> <li>oro-2.0.8.jar</li> <li>commons-io-2.2.jar</li> <li>commons-lang3-3.1.jar</li> </ul> <p><strong>Note</strong></p> <ul> <li>I also hardwired the path to jmeter.properties in c:\tmp on Windows after first copying it from the JMeter installation /bin directory.</li> <li>I wasn't sure how to set a forward proxy for the HTTPSampler.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload