Search in sources :

Example 16 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project TranslateIt-api by zunpiau.

the class WebConfig method configureMessageConverters.

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    ArrayList<MediaType> mediaTypes = new ArrayList<>(2);
    mediaTypes.add(new MediaType(MediaType.TEXT_PLAIN, StandardCharsets.UTF_8));
    mediaTypes.add(new MediaType(MediaType.TEXT_HTML, StandardCharsets.UTF_8));
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
    stringHttpMessageConverter.setSupportedMediaTypes(mediaTypes);
    MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
    jackson2HttpMessageConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
    converters.add(stringHttpMessageConverter);
    converters.add(jackson2HttpMessageConverter);
}
Also used : MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter) ArrayList(java.util.ArrayList) MediaType(org.springframework.http.MediaType) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter)

Example 17 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project thingsboard by thingsboard.

the class AbstractControllerTest method json.

@SuppressWarnings("unchecked")
protected String json(Object o) throws IOException {
    MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
    HttpMessageConverter converter = o instanceof String ? stringHttpMessageConverter : mappingJackson2HttpMessageConverter;
    converter.write(o, MediaType.APPLICATION_JSON, mockHttpOutputMessage);
    return mockHttpOutputMessage.getBodyAsString();
}
Also used : MockHttpOutputMessage(org.springframework.mock.http.MockHttpOutputMessage) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) MappingJackson2HttpMessageConverter(org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)

Example 18 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project codekvast by crispab.

the class DashboardApiControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    DashboardApiController dashboardApiController = new DashboardApiController(dashboardService, settings);
    this.mockMvc = MockMvcBuilders.standaloneSetup(dashboardApiController).setMessageConverters(new GsonHttpMessageConverter(), new StringHttpMessageConverter()).build();
}
Also used : GsonHttpMessageConverter(org.springframework.http.converter.json.GsonHttpMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) Before(org.junit.Before)

Example 19 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project molgenis by molgenis.

the class HttpClientConfig method converters.

private List<HttpMessageConverter<?>> converters() {
    List<HttpMessageConverter<?>> result = Lists.newArrayList();
    result.add(new ByteArrayHttpMessageConverter());
    result.add(new StringHttpMessageConverter());
    result.add(new ResourceHttpMessageConverter());
    result.add(new SourceHttpMessageConverter<>());
    result.add(new AllEncompassingFormHttpMessageConverter());
    result.add(new Jaxb2RootElementHttpMessageConverter());
    result.add(gsonHttpMessageConverter);
    return result;
}
Also used : Jaxb2RootElementHttpMessageConverter(org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter) ByteArrayHttpMessageConverter(org.springframework.http.converter.ByteArrayHttpMessageConverter) AllEncompassingFormHttpMessageConverter(org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) SourceHttpMessageConverter(org.springframework.http.converter.xml.SourceHttpMessageConverter) ResourceHttpMessageConverter(org.springframework.http.converter.ResourceHttpMessageConverter) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) GsonHttpMessageConverter(org.springframework.http.converter.json.GsonHttpMessageConverter) Jaxb2RootElementHttpMessageConverter(org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter) ResourceHttpMessageConverter(org.springframework.http.converter.ResourceHttpMessageConverter) ByteArrayHttpMessageConverter(org.springframework.http.converter.ByteArrayHttpMessageConverter) AllEncompassingFormHttpMessageConverter(org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter)

Example 20 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project osms by malikov-yurii.

the class SpringMvc method configureMessageConverters.

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
    stringHttpMessageConverter.setSupportedMediaTypes((Arrays.asList(MediaType.valueOf("text/plain;charset=UTF-8"), MediaType.valueOf("text/html;charset=UTF-8"))));
    converters.add(stringHttpMessageConverter);
    converters.add(converter());
}
Also used : StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter)

Aggregations

StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)91 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)46 ArrayList (java.util.ArrayList)38 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)25 ByteArrayHttpMessageConverter (org.springframework.http.converter.ByteArrayHttpMessageConverter)24 RestTemplate (org.springframework.web.client.RestTemplate)23 Test (org.junit.jupiter.api.Test)21 ResourceHttpMessageConverter (org.springframework.http.converter.ResourceHttpMessageConverter)18 Test (org.junit.Test)16 AllEncompassingFormHttpMessageConverter (org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter)16 MappingJackson2XmlHttpMessageConverter (org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter)11 MediaType (org.springframework.http.MediaType)9 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)9 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)9 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)7 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)7 URI (java.net.URI)7 HashMap (java.util.HashMap)7 Before (org.junit.Before)7 MethodParameter (org.springframework.core.MethodParameter)7