jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shivangi Tayal <shivithe...@gmail.com>
Subject Jmeter Web Sampler java api
Date Thu, 04 Dec 2014 10:39:27 GMT
Hi,

i want to send a soap request through eclipse in jmeter,using java api of
jmeter.

*my code is*:

package jmeter11;

import java.io.FileOutputStream;
import java.net.URL;
import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.engine.StandardJMeterEngine;
import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.protocol.http.sampler.WebServiceSampler;
import org.apache.jmeter.reporters.ResultCollector;
import org.apache.jmeter.reporters.Summariser;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jmeter.threads.ThreadGroup;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.collections.HashTree;

public class framewrk {
    public static void main(String[] argv) throws Exception {


        StandardJMeterEngine jmeter = new StandardJMeterEngine();
        JMeterUtils.setJMeterHome("C:\\Program
Files\\apache-jmeter-2.9\\apache-jmeter-2.9");
        JMeterUtils.loadJMeterProperties("C:\\Program
Files\\apache-jmeter-2.9\\apache-jmeter-2.9\\bin\\jmeter.properties");
        JMeterUtils.initLogging();
        JMeterUtils.initLocale();


        HashTree testPlanHashTree = new HashTree();


        WebServiceSampler wbs=new WebServiceSampler();
        wbs.setPath("/CurrencyConvertor.asmx");
        wbs.setPort(80);
        wbs.setSoapAction("http://www.webserviceX.NET/ConversionRate
<http://www.webservicex.net/ConversionRate>");
        wbs.setProtocol("http");
        wbs.setDomain("www.webservicex.net");
        wbs.setMaintainSession(true);
        wbs.setWsdlURL("
http://www.webservicex.net/CurrencyConvertor.asmx?WSDL");
        wbs.setAutoRedirects(true);
        wbs.setFollowRedirects(true);

wbs.setXmlPathLoc("C:\\Users\\tayals.CAMKMG-BL\\Desktop\\request.txt");
        wbs.setReadResponse(true);
        wbs.setMemoryCache(true);


        LoopController loopController = new LoopController();
        loopController.setLoops(1);
        loopController.addTestElement(wbs);
        loopController.setFirst(true);
        loopController.initialize();

        ThreadGroup threadGroup = new ThreadGroup();
        threadGroup.setName("Thread Group");
        threadGroup.setNumThreads(1);
        threadGroup.setRampUp(1);
        threadGroup.setSamplerController(loopController);

        TestPlan testPlan = new TestPlan();
        testPlan.setName("Test Plan");

        testPlanHashTree.add("testPlan", testPlan);
        testPlanHashTree.add("loopController", loopController);
        testPlanHashTree.add("threadGroup", threadGroup);
        testPlanHashTree.add("webserviceSampler", wbs);

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

        String logFile = "C:\\Program
Files\\apache-jmeter-2.9\\apache-jmeter-2.9\\bin\\framework.jtl";
        ResultCollector logger = new ResultCollector(summer);
        logger.loadExistingFile();

        logger.setFilename(logFile);
        testPlanHashTree.add(testPlanHashTree.getArray()[0], logger);
       // testPlanHashTree.add("listener",sr);
        SaveService.saveTree(testPlanHashTree, new
FileOutputStream("C:\\Program
Files\\apache-jmeter-2.9\\apache-jmeter-2.9\\bin\\examples\\Java
Request.jmx"));

        jmeter.configure(testPlanHashTree);
        jmeter.run();

    }
}

    *Console output*

INFO    2014-12-04 12:35:12.268 [jmeter.e] (): Listeners will be started
after enabling running version
INFO    2014-12-04 12:35:12.298 [jmeter.e] (): To revert to the earlier
behaviour, define jmeterengine.startlistenerslater=false
summary =      0 in     0s = ******/s Avg:     0 Min:     0 Max:     0 Err:
    0 (0.00%)

there is no summary,jtl file is also blank.Please reply ASAP

Regards
Shivangi Tayal

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message