REST-assured

REST-assured is an http testing framework. It is written mainly for REST apis but can be used for Soap, html and plain http as well.

Below is a simple example how to perform a HTTP GET call with REST-assured, and how to print out the response body

import static io.restassured.RestAssured.given;
import io.restassured.response.Response;

public class RestAssuredExample {

  public static void main(String[] args) {
    Response resp = given().when().get("http://localhost:8080");
    System.out.println(resp.getBody().asString());
  }
}

The request can be configured to do other HTTP methods, like POST and PUT, as well as setting body and headers.

given()
  .header("Connection", "keep-alive");
  .body("{}")
  .post("http://localhost:8000");

HTTPS / TLS (SSL)

If you want to call an endpoint over TLS, you need to relaxedHTTPSValidation to let the client trust the url destination

given().relaxedHTTPSValidation().post("https://localhost:8000");

LoadScenario

Below is a simple way you can construct a LoadScenario with REST-assured

LoadScenario scenario = new LoadScenario() {
  public void loadScenario() {
    load("greeting", ()->given().when().get("http://localhost:7060/api/greeting?name=Stefan"))
      .handleResult(resultHandler->{
        if(resultHandler.getResponse().getStatusCode() != 100) {
          resultHandler.setStatus(false);
        }
      })
      .perform();
    }
};

Maven dependencies

Here are the Maven dependencies you need to use rest-assured as the client library for your load tests

<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.3.3</version>
</dependency>