use of org.alfresco.repo.rendition2.RenditionDefinition2.TIMEOUT in project vertx-web by vert-x3.
the class RouterBuilderIntegrationTest method testComplexMultipart.
@Timeout(2000)
@Test
public void testComplexMultipart(Vertx vertx, VertxTestContext testContext) {
Checkpoint checkpoint = testContext.checkpoint(2);
loadBuilderAndStartServer(vertx, VALIDATION_SPEC, testContext, routerBuilder -> {
routerBuilder.setOptions(HANDLERS_TESTS_OPTIONS);
routerBuilder.operation("complexMultipartRequest").handler(routingContext -> {
RequestParameters params = routingContext.get("parsedParameters");
if (params.body() == null) {
routingContext.response().setStatusCode(200).end();
} else {
routingContext.response().putHeader("content-type", "application/json").setStatusCode(200).end(params.body().getJsonObject().toBuffer());
}
});
}).onComplete(h -> {
JsonObject pet = new JsonObject();
pet.put("id", 14612);
pet.put("name", "Willy");
MultipartForm form = MultipartForm.create().textFileUpload("param1", "random.txt", "src/test/resources/random.txt", "text/plain").attribute("param2", pet.encode()).textFileUpload("param3", "random.csv", "src/test/resources/random.txt", "text/csv").attribute("param4", "1.2").attribute("param4", "5.2").attribute("param4", "6.2").attribute("param5", "2").binaryFileUpload("param1NotRealBinary", "random-file", "src/test/resources/random-file", "text/plain").binaryFileUpload("param1Binary", "random-file", "src/test/resources/random-file", "application/octet-stream");
JsonObject expected = new JsonObject().put("param2", pet).put("param4", new JsonArray().add(1.2).add(5.2).add(6.2)).put("param5", 2);
testRequest(client, HttpMethod.POST, "/multipart/complex").expect(statusCode(200)).expect(jsonBodyResponse(expected)).sendMultipartForm(form, testContext, checkpoint);
testRequest(client, HttpMethod.POST, "/multipart/complex").expect(statusCode(200)).send(testContext, checkpoint);
});
}
Aggregations