use of org.springframework.http.converter.StringHttpMessageConverter in project spring-framework by spring-projects.
the class HeaderRequestMatchersIntegrationTests method setup.
@BeforeEach
public void setup() {
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new StringHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter());
this.restTemplate = new RestTemplate();
this.restTemplate.setMessageConverters(converters);
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
}
use of org.springframework.http.converter.StringHttpMessageConverter in project dhis2-core by dhis2.
the class WebMvcConfig method configureMessageConverters.
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
Arrays.stream(Compression.values()).forEach(compression -> converters.add(new JsonMessageConverter(nodeService(), compression)));
Arrays.stream(Compression.values()).forEach(compression -> converters.add(new XmlMessageConverter(nodeService(), compression)));
converters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new FormHttpMessageConverter());
converters.add(mappingJackson2HttpMessageConverter());
converters.add(mappingJackson2XmlHttpMessageConverter());
}
use of org.springframework.http.converter.StringHttpMessageConverter 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