0

I tried running the below code in eclipse which was posted here .

But it is not getting executed. It throws the following error:

NOTE: I also added external jars from jmeter installation file from lib/ext

Code:

public class JMeterFromScratch {

    public static void main(String[] args){
        // Engine
        StandardJMeterEngine jm = new StandardJMeterEngine();
        JMeterUtils.loadJMeterProperties("//Users//z001rdr//Documents//workspace//PerfTest//src//test//jmeter/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);

        Summariser summer = null;
        String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");//$NON-NLS-1$
        if (summariserName.length() > 0) {
            summer = new Summariser(summariserName);
        }

        String logFile = "/path/to/output/file.jtl";
        ResultCollector logger = new ResultCollector(summer);
        logger.setFilename(logFile);
       hashTree.add(hashTree.getArray()[0], logger);
        jm.run();
    }
}
Community
  • 1
  • 1
jmeter
  • 1
  • Log Files:DEBUG 2016-01-18 13:07:31.509 [jorphan.] (): Did not find: /Users/z001rdr/.m2/repository/excalibur-instrument/excalibur-instrument/1.0/excalibur-instrument-1.0.jar DEBUG 2016-01-18 13:07:31.509 [jorphan.] (): Did not find: /Users/z001rdr/.m2/repository/excalibur-logger/excalibur-logger/1.1/excalibur-logger-1.1.jar DEBUG 2016-01-18 13:07:31.509 [jorphan.] (): Did not find: /Users/z001rdr/.m2/repository/excalibur-pool/excalibur-pool/1.2/excalibur-pool-1.2.jar – jmeter Jan 18 '16 at 19:29
  • Please add the information in your comment into your question directly. – RaGe Jan 19 '16 at 00:26
  • Also looks like you're having a problem with maven not finding the required dependencies, and not with JMeter per-se. Make sure you have all required dependencies in your pom.xml and repositories configured correctly. – RaGe Jan 19 '16 at 00:28

1 Answers1

0

It looks like your Maven configuration is incorrect

Check out:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133