Search in sources :

Example 6 with MultiPartSpecBuilder

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

the class MultiPartITest method controlNameInMultiPartSpecBuilderHasPrecedenceOverDefault.

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

Example 7 with MultiPartSpecBuilder

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

the class MultiPartITest method inputStreamUploadingUsingMultiPartSpecification.

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

Example 8 with MultiPartSpecBuilder

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

the class MultiPartITest method fileNameCanBeNullInMultiPartSpec.

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

Example 9 with MultiPartSpecBuilder

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

the class MultiPartITest method defaultFileNameIsUsedWhenNoFileNameIsDefinedInMultiPartSpecBuilder.

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

Example 10 with MultiPartSpecBuilder

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

the class MultiPartITest method defaultFileNameCanBeNull.

@Test
public void defaultFileNameCanBeNull() throws Exception {
    // Given
    final InputStream is = getClass().getResourceAsStream("/car-records.xsd");
    // When
    given().config(RestAssuredConfig.config().multiPartConfig(multiPartConfig().with().emptyDefaultFileName())).multiPart(new MultiPartSpecBuilder(is).build()).when().post("/multipart/filename").then().body(isEmptyString()).statusCode(200);
}
Also used : InputStream(java.io.InputStream) 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