Search in sources :

Example 31 with ByteArrayHttpMessageConverter

use of org.springframework.http.converter.ByteArrayHttpMessageConverter 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());
}
Also used : FormHttpMessageConverter(org.springframework.http.converter.FormHttpMessageConverter) JsonMessageConverter(org.hisp.dhis.webapi.mvc.messageconverter.JsonMessageConverter) ByteArrayHttpMessageConverter(org.springframework.http.converter.ByteArrayHttpMessageConverter) XmlMessageConverter(org.hisp.dhis.webapi.mvc.messageconverter.XmlMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter)

Example 32 with ByteArrayHttpMessageConverter

use of org.springframework.http.converter.ByteArrayHttpMessageConverter in project vorto by eclipse.

the class RepositoryConfiguration method restTemplate.

@Bean
public RestTemplate restTemplate() {
    RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));
    List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
    interceptors.add(new LoggingInterceptor());
    restTemplate.setInterceptors(interceptors);
    restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter());
    return restTemplate;
}
Also used : SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) LoggingInterceptor(org.eclipse.vorto.repository.utils.LoggingInterceptor) RestTemplate(org.springframework.web.client.RestTemplate) ArrayList(java.util.ArrayList) ByteArrayHttpMessageConverter(org.springframework.http.converter.ByteArrayHttpMessageConverter) ClientHttpRequestInterceptor(org.springframework.http.client.ClientHttpRequestInterceptor) BufferingClientHttpRequestFactory(org.springframework.http.client.BufferingClientHttpRequestFactory) Bean(org.springframework.context.annotation.Bean)

Example 33 with ByteArrayHttpMessageConverter

use of org.springframework.http.converter.ByteArrayHttpMessageConverter in project incubator-servicecomb-java-chassis by apache.

the class TestRestTemplateWrapper method setMessageConvertersWithUnderlying.

@SuppressWarnings("unchecked")
@Test
public void setMessageConvertersWithUnderlying() {
    ByteArrayHttpMessageConverter messageConverter = mock(ByteArrayHttpMessageConverter.class);
    wrapper.setMessageConverters(singletonList(messageConverter));
    assertThat(wrapper.getMessageConverters(), contains(messageConverter));
    assertThat(wrapper.defaultRestTemplate.getMessageConverters(), contains(messageConverter));
    verify(underlying, never()).setMessageConverters(singletonList(messageConverter));
}
Also used : ByteArrayHttpMessageConverter(org.springframework.http.converter.ByteArrayHttpMessageConverter) Test(org.junit.Test)

Aggregations

ByteArrayHttpMessageConverter (org.springframework.http.converter.ByteArrayHttpMessageConverter)33 StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)17 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)13 ResourceHttpMessageConverter (org.springframework.http.converter.ResourceHttpMessageConverter)12 ArrayList (java.util.ArrayList)11 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)11 AllEncompassingFormHttpMessageConverter (org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter)11 RestTemplate (org.springframework.web.client.RestTemplate)7 Test (org.junit.jupiter.api.Test)6 Test (org.junit.Test)5 Bean (org.springframework.context.annotation.Bean)5 MediaType (org.springframework.http.MediaType)4 Jaxb2RootElementHttpMessageConverter (org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter)4 MappingJackson2XmlHttpMessageConverter (org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter)4 Method (java.lang.reflect.Method)3 MethodParameter (org.springframework.core.MethodParameter)3 GsonHttpMessageConverter (org.springframework.http.converter.json.GsonHttpMessageConverter)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2