Java Code Examples for io.restassured.RestAssured#registerParser()
The following examples show how to use
io.restassured.RestAssured#registerParser() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadApiIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Test @TestsNotMeantForZowe public void shouldSendGetRequestAndDownloadCompressedImage() { RestAssured.registerParser("image/png", Parser.JSON); URI uri = HttpRequestUtils.getUriFromGateway("/api/v1/discoverableclient/get-file"); given(). contentType("application/octet-stream"). accept("image/png"). when(). get(uri). then(). statusCode(200). header("Content-Disposition", "attachment;filename=api-catalog.png"). header("Content-Encoding", "gzip"). contentType("image/png"); }
Example 2
Source File: MailRepositoriesRoutesTest.java From james-project with Apache License 2.0 | 6 votes |
@Test public void downloadingAMailShouldFailWhenUnknown() throws Exception { mailRepositoryStore.create(URL_MY_REPO); RestAssured.requestSpecification = new RequestSpecBuilder().setPort(webAdminServer.getPort().getValue()) .setBasePath(MailRepositoriesRoutes.MAIL_REPOSITORIES) .build(); RestAssured.registerParser(Constants.RFC822_CONTENT_TYPE, Parser.TEXT); String name = "name"; given() .accept(Constants.RFC822_CONTENT_TYPE) .when() .get(PATH_ESCAPED_MY_REPO + "/mails/" + name) .then() .statusCode(HttpStatus.NOT_FOUND_404) .body("statusCode", is(404)) .body("type", is(ErrorResponder.ErrorType.NOT_FOUND.getType())) .body("message", is("Could not retrieve " + name)); }
Example 3
Source File: MultipartPutIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test @TestsNotMeantForZowe public void shouldDoPutRequestAndMatchReturnBody() { RestAssured.registerParser("text/plain", Parser.JSON); URI uri = HttpRequestUtils.getUriFromGateway(MULTIPART_PATH); given(). contentType("multipart/form-data"). multiPart(new File(classLoader.getResource(configFileName).getFile())). expect(). statusCode(200). body("fileName", equalTo("example.txt")). body("fileType", equalTo("application/octet-stream")). when(). put(uri); }
Example 4
Source File: MultipartPutIntegrationTest.java From api-layer with Eclipse Public License 2.0 | 5 votes |
@Test @TestsNotMeantForZowe public void shouldDoPostRequestAndMatchReturnBody() { RestAssured.registerParser("text/plain", Parser.JSON); URI uri = HttpRequestUtils.getUriFromGateway(MULTIPART_PATH); given(). contentType("multipart/form-data"). multiPart(new File(classLoader.getResource(configFileName).getFile())). expect(). statusCode(200). body("fileName", equalTo("example.txt")). body("fileType", equalTo("application/octet-stream")). when(). post(uri); }
Example 5
Source File: MailRepositoriesRoutesTest.java From james-project with Apache License 2.0 | 5 votes |
@Test public void downloadingAMailShouldReturnTheEml() throws Exception { RestAssured.requestSpecification = new RequestSpecBuilder().setPort(webAdminServer.getPort().getValue()) .setBasePath(MailRepositoriesRoutes.MAIL_REPOSITORIES) .build(); RestAssured.registerParser(Constants.RFC822_CONTENT_TYPE, Parser.TEXT); MailRepository mailRepository = mailRepositoryStore.create(URL_MY_REPO); String name = NAME_1; FakeMail mail = FakeMail.builder() .name(name) .fileName("mail.eml") .build(); mailRepository.store(mail); String expectedContent = ClassLoaderUtils.getSystemResourceAsString("mail.eml", StandardCharsets.UTF_8); String actualContent = given() .accept(Constants.RFC822_CONTENT_TYPE) .when() .get(PATH_ESCAPED_MY_REPO + "/mails/" + name) .then() .statusCode(HttpStatus.OK_200) .header("Content-Length", "471") .contentType(Constants.RFC822_CONTENT_TYPE) .extract() .body() .asString(); assertThat(actualContent).isEqualToNormalizingNewlines(expectedContent); }