use of org.springframework.mock.http.MockHttpInputMessage in project thingsboard by thingsboard.
the class AbstractControllerTest method readResponse.
@SuppressWarnings("unchecked")
protected <T> T readResponse(ResultActions result, Class<T> responseClass) throws Exception {
byte[] content = result.andReturn().getResponse().getContentAsByteArray();
MockHttpInputMessage mockHttpInputMessage = new MockHttpInputMessage(content);
HttpMessageConverter converter = responseClass.equals(String.class) ? stringHttpMessageConverter : mappingJackson2HttpMessageConverter;
return (T) converter.read(responseClass, mockHttpInputMessage);
}
use of org.springframework.mock.http.MockHttpInputMessage in project irida by phac-nml.
the class SequenceFileMessageConverterTest method testRead.
@Test
public void testRead() throws HttpMessageNotReadableException, IOException {
String message = "Some fastq file";
HttpInputMessage inputMessage = new MockHttpInputMessage(message.getBytes());
Path read = converter.read(Path.class, inputMessage);
assertTrue(Files.exists(read));
byte[] fileBytes = Files.readAllBytes(read);
assertEquals(message, new String(fileBytes));
Files.delete(read);
}
use of org.springframework.mock.http.MockHttpInputMessage in project thingsboard by thingsboard.
the class AbstractWebTest method readResponse.
@SuppressWarnings("unchecked")
protected <T> T readResponse(ResultActions result, Class<T> responseClass) throws Exception {
byte[] content = result.andReturn().getResponse().getContentAsByteArray();
MockHttpInputMessage mockHttpInputMessage = new MockHttpInputMessage(content);
HttpMessageConverter converter = responseClass.equals(String.class) ? stringHttpMessageConverter : mappingJackson2HttpMessageConverter;
return (T) converter.read(responseClass, mockHttpInputMessage);
}
Aggregations