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"))));
}
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");
}
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);
}
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"));
}
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);
}
Aggregations