use of io.restassured.http.Header in project rest-assured by rest-assured.
the class HeaderITest method requestSpecificationAllowsSpecifyingHeadersObject.
@Test
public void requestSpecificationAllowsSpecifyingHeadersObject() throws Exception {
final Header header1 = new Header("MyHeader", "Something");
final Header header2 = new Header("MyHeader", "Something else");
final Headers headers = new Headers(header1, header2);
final List<String> myHeaderValues = given().headers(headers).when().get("/multiHeaderReflect").headers().getValues("MyHeader");
assertThat(myHeaderValues.size(), is(2));
assertThat(myHeaderValues, hasItems("Something", "Something else"));
}
use of io.restassured.http.Header in project rest-assured by rest-assured.
the class HeaderITest method orderIsMaintainedForMultiValueHeaders.
@Test
public void orderIsMaintainedForMultiValueHeaders() throws Exception {
Headers headers = when().get("/multiValueHeader").headers();
final List<String> headerListString = headers.getValues("MultiHeader");
final String firstValue = headers.getValue("MultiHeader");
final List<Header> headerListHeader = headers.getList("MultiHeader");
assertThat(headerListString, contains("Value 1", "Value 2"));
assertThat(headerListHeader, contains(new Header("MultiHeader", "Value 1"), new Header("MultiHeader", "Value 2")));
assertThat(firstValue, equalTo("Value 2"));
}
use of io.restassured.http.Header in project rest-assured by rest-assured.
the class HeaderConfigITest method request_spec_overwrites_headers_when_configured_in_header_config.
@Test
public void request_spec_overwrites_headers_when_configured_in_header_config() {
RequestSpecification specification = new RequestSpecBuilder().addHeader("header1", "value2").build();
List<Header> list = given().config(RestAssuredConfig.config().headerConfig(HeaderConfig.headerConfig().overwriteHeadersWithName("header1"))).header("header1", "value1").spec(specification).when().get("/multiHeaderReflect").then().extract().headers().getList("header1");
assertThat(list, hasSize(1));
assertThat(list.get(0).getValue(), equalTo("value2"));
}
use of io.restassured.http.Header in project rest-assured by rest-assured.
the class HeaderConfigITest method request_spec_merges_headers_by_default.
@Test
public void request_spec_merges_headers_by_default() {
RequestSpecification specification = new RequestSpecBuilder().addHeader("header1", "value2").build();
List<Header> list = given().header("header1", "value1").spec(specification).when().get("/multiHeaderReflect").then().extract().headers().getList("header1");
assertThat(list, hasSize(2));
}
use of io.restassured.http.Header in project rest-assured by rest-assured.
the class ResponsePrinter method toString.
private static String toString(Headers headers) {
if (!headers.exist()) {
return "";
}
final StringBuilder builder = new StringBuilder();
for (Header header : headers) {
builder.append(header.getName()).append(HEADER_NAME_AND_VALUE_SEPARATOR).append(header.getValue()).append("\n");
}
builder.deleteCharAt(builder.length() - 1);
return builder.toString();
}
Aggregations