use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class SpecificationBuilderITest method mergesStaticallyDefinedRequestSpecificationsCorrectly.
@Test
public void mergesStaticallyDefinedRequestSpecificationsCorrectly() throws Exception {
RestAssured.requestSpecification = new RequestSpecBuilder().addCookie("Cookie1", "Value1").build();
RequestSpecification reqSpec1 = new RequestSpecBuilder().addCookie("Cookie2", "Value2").build();
RequestSpecification reqSpec2 = new RequestSpecBuilder().addCookie("Cookie3", "Value3").build();
try {
Cookies cookies = given().spec(reqSpec1).when().get("/reflect").then().extract().detailedCookies();
assertThat(cookies.size(), is(2));
assertThat(cookies.hasCookieWithName("Cookie1"), is(true));
assertThat(cookies.hasCookieWithName("Cookie2"), is(true));
cookies = given().spec(reqSpec2).when().get("/reflect").then().extract().detailedCookies();
assertThat(cookies.size(), is(2));
assertThat(cookies.hasCookieWithName("Cookie1"), is(true));
assertThat(cookies.hasCookieWithName("Cookie3"), is(true));
} finally {
RestAssured.reset();
}
}
use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class SpecificationBuilderITest method supportsMergingMultiValueQueryParametersWhenUsingRequestSpecBuilder.
@Test
public void supportsMergingMultiValueQueryParametersWhenUsingRequestSpecBuilder() throws Exception {
final RequestSpecification spec = new RequestSpecBuilder().addQueryParam("list", "1", "2", "3").build();
given().spec(spec).expect().body("list", equalTo("1,2,3")).when().get("/multiValueParam");
}
use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class SpecificationBuilderITest method supportsMergingHeadersWhenUsingRequestSpecBuilder.
@Test
public void supportsMergingHeadersWhenUsingRequestSpecBuilder() throws Exception {
final RequestSpecification spec = new RequestSpecBuilder().addHeader("header1", "value1").build();
given().spec(spec).header("header2", "value2").expect().body(containsString("header1")).body(containsString("header2")).when().get("/header");
}
use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class URLEncodingITest method urlEncodingDisabledUsingRequestSpecBuilder.
@Test
@Ignore("2.0.alpha1 no longer working")
public void urlEncodingDisabledUsingRequestSpecBuilder() {
final RequestSpecification specification = new RequestSpecBuilder().setUrlEncodingEnabled(false).build();
final String body = given().specification(specification).get("https://jira.atlassian.com:443/rest/api/2.0.alpha1/search?jql=project%20=%20BAM%20AND%20issuetype%20=%20Bug").asString();
assertThat(body, containsString("issues"));
}
use of io.restassured.builder.RequestSpecBuilder in project rest-assured by rest-assured.
the class MultiPartUploadITest method bytesAndFormParamUploadingWorkUsingRequestBuilder.
@Test
public void bytesAndFormParamUploadingWorkUsingRequestBuilder() throws Exception {
final byte[] bytes = IOUtils.toByteArray(getClass().getResourceAsStream("/car-records.xsd"));
final RequestSpecification spec = new RequestSpecBuilder().addMultiPart("file", "myFile", bytes).addFormParam("text", "Some text").build();
// When
given().spec(spec).expect().body(is(new String(bytes) + "Some text")).when().post("/multipart/fileAndText");
}
Aggregations