Java Code Examples for io.restassured.response.Response#getContentType()
The following examples show how to use
io.restassured.response.Response#getContentType() .
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: HistoricVariableInstanceRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testGetBinaryDataForFileVariable() { String filename = "test.txt"; byte[] byteContent = "test".getBytes(); String encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create(); HistoricVariableInstance variableInstanceMock = MockProvider.mockHistoricVariableInstance().typedValue(variableValue).build(); when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID) .then().expect() .statusCode(Status.OK.getStatusCode()) .and() .body(is(equalTo(new String(byteContent)))) .header("Content-Disposition", "attachment; filename=\"" + filename + "\"") .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); //due to some problems with wildfly we gotta check this separately String contentType = response.getContentType(); assertThat(contentType, is(either(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + "; charset=UTF-8")).or(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + ";charset=UTF-8")))); verify(variableInstanceQueryMock, never()).disableBinaryFetching(); }
Example 2
Source File: VariableInstanceRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testGetBinaryDataForFileVariable() { String filename = "test.txt"; byte[] byteContent = "test".getBytes(); String encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create(); MockVariableInstanceBuilder builder = MockProvider.mockVariableInstance(); VariableInstance variableInstanceMock = builder .typedValue(variableValue) .build(); when(variableInstanceQueryMock.variableId(variableInstanceMock.getId())).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock); when(variableInstanceQueryMock.singleResult()).thenReturn(variableInstanceMock); Response response = given().pathParam("id", MockProvider.EXAMPLE_VARIABLE_INSTANCE_ID) .then().expect().statusCode(Status.OK.getStatusCode()) .and() .header("Content-Disposition", "attachment; filename=\"" + filename + "\"") .and() .body(is(equalTo(new String(byteContent)))) .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); //due to some problems with wildfly we gotta check this separately String contentType = response.getContentType(); assertThat(contentType, is(either(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + "; charset=UTF-8")).or(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + ";charset=UTF-8")))); }
Example 3
Source File: HistoricDetailRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testBinaryDataForFileVariable() { String filename = "test.txt"; byte[] byteContent = "test".getBytes(); String encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create(); MockHistoricVariableUpdateBuilder builder = MockProvider.mockHistoricVariableUpdate(); HistoricVariableUpdate detailMock = builder .typedValue(variableValue) .build(); when(historicDetailQueryMock.detailId(detailMock.getId())).thenReturn(historicDetailQueryMock); when(historicDetailQueryMock.disableCustomObjectDeserialization()).thenReturn(historicDetailQueryMock); when(historicDetailQueryMock.singleResult()).thenReturn(detailMock); Response response = given().pathParam("id", MockProvider.EXAMPLE_HISTORIC_VAR_UPDATE_ID) .then().expect() .statusCode(Status.OK.getStatusCode()) . body(is(equalTo(new String(byteContent)))) .and() .header("Content-Disposition", "attachment; filename=\"" + filename + "\"") .when().get(VARIABLE_INSTANCE_BINARY_DATA_URL); //due to some problems with wildfly we gotta check this separately String contentType = response.getContentType(); assertThat(contentType, is(either(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + "; charset=UTF-8")).or(CoreMatchers.<Object>equalTo(ContentType.TEXT.toString() + ";charset=UTF-8")))); verify(historicDetailQueryMock, never()).disableBinaryFetching(); }