Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Rest Assured: Validate Response Headers

'header' method is used to Validate the Response Headers. For example, below snippet verifies response content type.

Example
given().header("Accept", "application/json")
       .when().get("api/v1/employees/")
       .then().assertThat().statusCode(200).and()
       .header("Content-Type", "application/json;charset=UTF-8");

TestApp.java

package com.sample.app;

import static io.restassured.RestAssured.given;

import org.junit.Test;

import io.restassured.RestAssured;

public class TestApp {

@Test
public void testApp() {
RestAssured.baseURI = "http://localhost:8080";

given().header("Accept", "application/json").when().get("api/v1/employees/").then().assertThat().statusCode(200)
.and().header("Content-Type", "application/json;charset=UTF-8");

}

}



Previous                                                    Next                                                    Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Rest Assured: Validate Response Headers

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×