Search in sources :

Example 11 with RequestSpecification

use of io.restassured.specification.RequestSpecification 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");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 12 with RequestSpecification

use of io.restassured.specification.RequestSpecification 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");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 13 with RequestSpecification

use of io.restassured.specification.RequestSpecification 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"));
}
Also used : FilterableRequestSpecification(io.restassured.specification.FilterableRequestSpecification) RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with RequestSpecification

use of io.restassured.specification.RequestSpecification 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");
}
Also used : RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Example 15 with RequestSpecification

use of io.restassured.specification.RequestSpecification in project rest-assured by rest-assured.

the class FilterITest method defaultFiltersDontAccumluate.

/**
 * Regression Test for 197
 */
@Test
public void defaultFiltersDontAccumluate() {
    CountingFilter myFilter = new CountingFilter();
    try {
        RestAssured.config = RestAssuredConfig.newConfig();
        RestAssured.filters(myFilter);
        RequestSpecification spec = new RequestSpecBuilder().build();
        given().get("/greetJSON?firstName=John&lastName=Doe");
        assertThat(myFilter.counter, equalTo(1));
        given().spec(spec).get("/greetJSON?firstName=Johan&lastName=Doe");
        assertThat(myFilter.counter, equalTo(2));
    } finally {
        RestAssured.reset();
    }
}
Also used : FilterableRequestSpecification(io.restassured.specification.FilterableRequestSpecification) RequestSpecification(io.restassured.specification.RequestSpecification) RequestSpecBuilder(io.restassured.builder.RequestSpecBuilder) Test(org.junit.Test)

Aggregations

RequestSpecification (io.restassured.specification.RequestSpecification)55 Test (org.junit.Test)47 RequestSpecBuilder (io.restassured.builder.RequestSpecBuilder)40 FilterableRequestSpecification (io.restassured.specification.FilterableRequestSpecification)7 SecurityTest (com.capgemini.ntc.security.SecurityTest)6 ResponseSpecification (io.restassured.specification.ResponseSpecification)5 Filter (io.restassured.filter.Filter)4 Parameters (junitparams.Parameters)4 FilterContext (io.restassured.filter.FilterContext)3 Header (io.restassured.http.Header)3 Response (io.restassured.response.Response)3 FilterableResponseSpecification (io.restassured.specification.FilterableResponseSpecification)3 PrintStream (java.io.PrintStream)3 StringWriter (java.io.StringWriter)3 WriterOutputStream (org.apache.commons.io.output.WriterOutputStream)3 RestDocumentationFilter (org.springframework.restdocs.restassured3.RestDocumentationFilter)3 Headers (io.restassured.http.Headers)2 List (java.util.List)2 MutableObject (org.apache.commons.lang3.mutable.MutableObject)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1