gijugeorge

2 posts

REST stands for "Representational State Transfer". It is just a software architectural style, or a set of design rules that can be used to write web services. Because it is a style, there are no standards defined for this.

How does REST works?
Representational State Transafer means the state of the client changes based on the representation of the resource. Imagine surfing a web page using a URL. When you access the URL, a page (resource) is returned to you. When you select another page, a different representation of the resource is retuned. Based on the the representation returned, the state of the client (calling application) also changes.


       public static void main(String args[]){
                Sysout
        }
        





Apache JMeter is an open source tool that can be used to measure the performance of Java applications. The JMeter can be used to test a wide range of Java applications like web, EJB, web services etc. I am not going to elaborate more on this, and you can get more information about this from the Apache JMeter website at http://jakarta.apache.org/jmeter/

The JMeter can also be extended, to create your own test plans. In this section I will explain the steps needed to create a custom JavaRequest sampler, and run it using JMeter.

To write the code you need to add the ApacheJMeter jar files to your classpath. The below code describes the simple JavaSampler:


package com.test;

import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerClient;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;

/**
 *
 * @author ggeorge
 */
public class MyTestJavaSampler implements JavaSamplerClient {

    public void setupTest(JavaSamplerContext arg0) {
        
    }

    public SampleResult runTest(JavaSamplerContext arg0) {
        
        SampleResult sr = new SampleResult();
        sr.sampleStart();
        sr.setResponseMessage("This is my first message");
        sr.sampleEnd();
        sr.setSuccessful(true);
        return sr;
    }

    public void teardownTest(JavaSamplerContext arg0) {
    }

    public Arguments getDefaultParameters() {
        Arguments args = new Arguments();
        args.addArgument("Name", "");
        args.addArgument("Password", "");
        return args;
    }
}

  • Create a jar file for this code, and place in under the <jmeter_install_dir>/lib/ext directory.
  • Start JMeter and when you try to create a new JavaRequest sampler, you should be able to select the new class that you created.

You can customize this class for whatever performance test you want to run.

jmeter.jpg