Search in sources :

Example 1 with MappingJackson2HttpMessageConverter

use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project spring-boot-admin by codecentric.

the class AdminServerWebConfigurationTest method jacksonMapperPresentFromDefault.

@Test
public void jacksonMapperPresentFromDefault() {
    AdminServerWebConfiguration config = new AdminServerWebConfiguration(null, null, null, null);
    List<HttpMessageConverter<?>> converters = new ArrayList<>();
    converters.add(new MappingJackson2HttpMessageConverter());
    config.extendMessageConverters(converters);
    assertThat(converters, hasItem(isA(MappingJackson2HttpMessageConverter.class)));
    assertThat(converters.size(), is(1));
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) ArrayList(java.util.ArrayList) MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) Test(org.junit.Test)

Example 2 with MappingJackson2HttpMessageConverter

use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project mirrorgate-jira-stories-collector by BBVA.

the class Config method getRestTemplate.

@Bean(MIRRORGATE_REST_TEMPLATE)
public RestTemplate getRestTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    MappingJackson2HttpMessageConverter jsonHttpMessageConverter = new MappingJackson2HttpMessageConverter();
    restTemplate.getMessageConverters().add(jsonHttpMessageConverter);
    if (mirrorGateUserName.isPresent() && !mirrorGateUserName.get().isEmpty()) {
        restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(mirrorGateUserName.get(), mirrorGatePassword.get()));
    }
    return restTemplate;
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) RestTemplate(org.springframework.web.client.RestTemplate) BasicAuthorizationInterceptor(org.springframework.http.client.support.BasicAuthorizationInterceptor) Bean(org.springframework.context.annotation.Bean)

Example 3 with MappingJackson2HttpMessageConverter

use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project Activiti by Activiti.

the class DispatcherServletConfiguration method configureMessageConverters.

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    addDefaultHttpMessageConverters(converters);
    for (HttpMessageConverter<?> converter : converters) {
        if (converter instanceof MappingJackson2HttpMessageConverter) {
            MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = (MappingJackson2HttpMessageConverter) converter;
            jackson2HttpMessageConverter.setObjectMapper(objectMapper);
            break;
        }
    }
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)

Example 4 with MappingJackson2HttpMessageConverter

use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project Activiti by Activiti.

the class DispatcherServletConfiguration method configureMessageConverters.

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    addDefaultHttpMessageConverters(converters);
    for (HttpMessageConverter<?> converter : converters) {
        if (converter instanceof MappingJackson2HttpMessageConverter) {
            MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = (MappingJackson2HttpMessageConverter) converter;
            jackson2HttpMessageConverter.setObjectMapper(objectMapper);
            break;
        }
    }
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)

Example 5 with MappingJackson2HttpMessageConverter

use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project cas by apereo.

the class RegisteredServiceResourceTests method configureMockMvcFor.

private MockMvc configureMockMvcFor(final RegisteredServiceResource registeredServiceResource) {
    final DefaultRegisteredServiceJsonSerializer sz = new DefaultRegisteredServiceJsonSerializer();
    final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(sz.getObjectMapper());
    return MockMvcBuilders.standaloneSetup(registeredServiceResource).defaultRequest(get("/").contextPath("/cas").contentType(MediaType.APPLICATION_JSON)).setMessageConverters(converter).build();
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) DefaultRegisteredServiceJsonSerializer(org.apereo.cas.services.util.DefaultRegisteredServiceJsonSerializer)

Aggregations

MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)122 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)51 ArrayList (java.util.ArrayList)46 StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)38 Test (org.junit.jupiter.api.Test)28 ByteArrayHttpMessageConverter (org.springframework.http.converter.ByteArrayHttpMessageConverter)25 RestTemplate (org.springframework.web.client.RestTemplate)25 MappingJackson2XmlHttpMessageConverter (org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter)21 ResourceHttpMessageConverter (org.springframework.http.converter.ResourceHttpMessageConverter)20 AllEncompassingFormHttpMessageConverter (org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter)19 HandlerMethod (org.springframework.web.method.HandlerMethod)17 Method (java.lang.reflect.Method)16 Test (org.junit.Test)16 MethodParameter (org.springframework.core.MethodParameter)16 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)15 Bean (org.springframework.context.annotation.Bean)14 List (java.util.List)9 HttpEntity (org.springframework.http.HttpEntity)7 MediaType (org.springframework.http.MediaType)6 HttpComponentsClientHttpRequestFactory (org.springframework.http.client.HttpComponentsClientHttpRequestFactory)6