Search in sources :

Example 16 with MultiPartSpecBuilder

use of io.restassured.builder.MultiPartSpecBuilder in project rest-assured by rest-assured.

the class MultiPartITest method textUploadingWhenUsingMultiPartSpecificationAndCharset.

@Test
public void textUploadingWhenUsingMultiPartSpecificationAndCharset() throws Exception {
    // Given
    final String string = IOUtils.toString(getClass().getResourceAsStream("/car-records.xsd"));
    // When
    given().multiPart(new MultiPartSpecBuilder(string).with().charset("UTF-8").and().with().controlName("other").and().with().mimeType("application/vnd.some+json").build()).expect().statusCode(200).body(is(string)).when().post("/multipart/string");
}
Also used : MultiPartSpecBuilder(io.restassured.builder.MultiPartSpecBuilder) Test(org.junit.Test)

Example 17 with MultiPartSpecBuilder

use of io.restassured.builder.MultiPartSpecBuilder in project rest-assured by rest-assured.

the class MultiPartITest method fileNameInMultiPartSpecBuilderHasPrecedenceOverDefault.

@Test
public void fileNameInMultiPartSpecBuilderHasPrecedenceOverDefault() throws Exception {
    // Given
    final InputStream is = getClass().getResourceAsStream("/car-records.xsd");
    // When
    given().multiPart(new MultiPartSpecBuilder(is).fileName("file2").build()).when().post("/multipart/filename").then().statusCode(200).body(equalTo("file2"));
}
Also used : InputStream(java.io.InputStream) MultiPartSpecBuilder(io.restassured.builder.MultiPartSpecBuilder) Test(org.junit.Test)

Example 18 with MultiPartSpecBuilder

use of io.restassured.builder.MultiPartSpecBuilder in project rest-assured by rest-assured.

the class MultiPartUploadITest method multiPartObjectMapperTypeHavePrecedenceOverMimeType.

@Test
public void multiPartObjectMapperTypeHavePrecedenceOverMimeType() throws Exception {
    // Given
    final Greeting greeting = new Greeting();
    greeting.setFirstName("John");
    greeting.setLastName("Doe");
    // When
    given().multiPart(new MultiPartSpecBuilder(greeting, ObjectMapperType.JAXB).fileName("RoleBasedAccessFeaturePlan.csv").controlName("text").mimeType("application/json").build()).when().post("/multipart/text").then().statusCode(200).body(containsString("John"), containsString("Doe"), containsString("<"));
}
Also used : Greeting(io.restassured.itest.java.objects.Greeting) MultiPartSpecBuilder(io.restassured.builder.MultiPartSpecBuilder) Test(org.junit.Test)

Aggregations

MultiPartSpecBuilder (io.restassured.builder.MultiPartSpecBuilder)18 Test (org.junit.Test)17 InputStream (java.io.InputStream)9 Greeting (io.restassured.itest.java.objects.Greeting)6 NoAuthScheme (io.restassured.authentication.NoAuthScheme)1 RequestSpecificationImpl (io.restassured.internal.RequestSpecificationImpl)1 FilterContextImpl (io.restassured.internal.filter.FilterContextImpl)1 Jackson2Mapper (io.restassured.internal.mapping.Jackson2Mapper)1 DefaultJackson2ObjectMapperFactory (io.restassured.mapper.factory.DefaultJackson2ObjectMapperFactory)1 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)1