0
votes

Actually I wanna do the performance test between web service and EJB Remote on JMeter desktop application. I have tow java classes with main method and I call the webservice and lookup EJB Remote from them.
Easily I used "System.currentTimeMillis()" method befor and after call webservice and lookup EJB Remote and calculated how long both of them take to response .
Now I wanna to run performance test on them and I found JMete is on of the Test Client Tools. could any body please help me how to do it, or any better idead to do it .

Thank you in advance

2
Move your mouse over the jmeter tag above and click info in the corresponding popup - lots of links at the bottom.home

2 Answers

0
votes

Use the below link for your reference to Invoke Web-Services using Jmeter:

https://stackoverflow.com/a/26269507/3547653

Hope this will help.

0
votes

Actually I did those test by modifying EJB and WS classes by extends them from "AbstractJavaSamplerClient" and added my codes on "runTest()" method like this :
Web Service Sample

    public SampleResult runTest(JavaSamplerContext context) {
    SampleResult result = new SampleResult();
    String result1 = "";

    try{

        JMeterVariables vars = JMeterContextService.getContext().getVariables();
        vars.put("WebService", "WebServiceVariableContent");
        result.sampleStart();



        HelloWorldService service = new HelloWorldService();
        HelloWorldPortType port = service.getHelloWorldPortTypePort();
        long s = System.currentTimeMillis();
        result1 = port.sayHelloWorld("10000", "500");
        long f = System.currentTimeMillis();
        LogUtil.log("******** WEB SRVICE ********  Start on : " + s
                + " and end at : " + f + " --> Webservice takes " + (f - s)
                / 1000 + " second", Level.INFO, null);
        System.out.println("********* RESULT from WebService ***********");
        System.out.println(result);
        System.out.println("********************************************");



        result.sampleEnd();
        result.setSuccessful(true);
        result.setSampleLabel("SUCCESS: " + result1);


    } catch (Throwable e) {
    result.sampleEnd();
    result.setSampleLabel("FAILED: '" + e.getMessage() + "' || " + e.toString());
    result.setSuccessful(false);
    e.printStackTrace();
    System.out.println("\n\n\n");
    }

    return result;
}

EJB Remote Sample

    public SampleResult runTest(JavaSamplerContext context) {
    SampleResult result = new SampleResult();
    String result1 = "";

    try{

        JMeterVariables vars = JMeterContextService.getContext().getVariables();
        vars.put("EJBRemote", "EJBRemoteVariableContent");
        result.sampleStart();


        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "weblogic.jndi.WLInitialContextFactory");
        env.put(Context.SECURITY_PRINCIPAL, "weblogic");
        env.put(Context.SECURITY_CREDENTIALS, "weblogic");
        env.put(Context.PROVIDER_URL, "t3://46.34.96.70:1087");
        Context ctx = new InitialContext(env);
        System.out.println("Initial Context created");
        long s = System.currentTimeMillis();

        helloWorld = (HelloWorld) ctx
                .lookup("HelloWorld#server.com.demo.HelloWorld");
        long f = System.currentTimeMillis();
        LogUtil.log("******** EJB REMOTE ********  Start on : "+s+" and end at : "+f+" --> Webservice takes "+(f - s)/1000 + " second",Level.INFO, null);       

        System.out.println("lookup successful");
        System.out.println("Calling EJB method . . .");
        result1=helloWorld.sayHello("10000","50000");
        System.out.println("Output will be in Managed server console");
        System.out.println("********* RESULT from EJB Remote ***********");
        System.out.println(result1);        
        System.out.println("********************************************");


        result.sampleEnd();
        result.setSuccessful(true);
        result.setSampleLabel("SUCCESS: " + result1);

    } catch (Throwable e) {
        result.sampleEnd();
        result.setSampleLabel("FAILED: '" + e.getMessage() + "' || " + e.toString());
        result.setSuccessful(false);
        e.printStackTrace();
        System.out.println("\n\n\n");
        }

    return result;
}

Then You should create jar files from them (Easily I just used export option in MyEclipse) and copy them (with external jar files if need) to JMETER_HOME/lib/ext .
Further from JMeter desktop application I added "Java Request" sampler and chose the my desired class from classname option.
Now you could add some listener to see the test results .
Hope it could be helpful.