use of org.springframework.http.converter.StringHttpMessageConverter in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method defaultMessageConvertersShouldClearExisting.
@Test
void defaultMessageConvertersShouldClearExisting() {
RestTemplate template = new RestTemplate(Collections.singletonList(new StringHttpMessageConverter()));
this.builder.additionalMessageConverters(this.messageConverter).defaultMessageConverters().configure(template);
assertThat(template.getMessageConverters()).hasSameSizeAs(new RestTemplate().getMessageConverters());
}
use of org.springframework.http.converter.StringHttpMessageConverter in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method defaultMessageConvertersShouldSetDefaultList.
@Test
void defaultMessageConvertersShouldSetDefaultList() {
RestTemplate template = new RestTemplate(Collections.singletonList(new StringHttpMessageConverter()));
this.builder.defaultMessageConverters().configure(template);
assertThat(template.getMessageConverters()).hasSameSizeAs(new RestTemplate().getMessageConverters());
}
use of org.springframework.http.converter.StringHttpMessageConverter in project dhis2-core by dhis2.
the class MvcTestConfig 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());
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new FormHttpMessageConverter());
converters.add(mappingJackson2HttpMessageConverter());
converters.add(mappingJackson2XmlHttpMessageConverter());
}
use of org.springframework.http.converter.StringHttpMessageConverter in project xm-ms-entity by xm-online.
the class TemplateUtil method getTemplate.
public static RestTemplate getTemplate(ClientHttpRequestInterceptor interceptor) {
RestTemplate restTemplate = new RestTemplate();
List<ClientHttpRequestInterceptor> ris = new ArrayList<>();
ris.add(interceptor);
restTemplate.setInterceptors(ris);
SimpleClientHttpRequestFactory httpFactory = new SimpleClientHttpRequestFactory();
httpFactory.setOutputStreaming(false);
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(httpFactory));
restTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
return restTemplate;
}
use of org.springframework.http.converter.StringHttpMessageConverter in project webapp by elimu-ai.
the class MarkupValidationHelper method verifyNoMarkupError.
/**
* Verifies that the HTML is well formed.
*
* @param markup The HTML markup to be tested.
*/
public static void verifyNoMarkupError(String markup) {
// List<MediaType> supportedMediaTypes = new ArrayList<>();
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>();
supportedMediaTypes.add(new MediaType("text", "html", Charset.forName("UTF-8")));
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
stringHttpMessageConverter.setSupportedMediaTypes(supportedMediaTypes);
// List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
messageConverters.add(stringHttpMessageConverter);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setMessageConverters(messageConverters);
String result = restTemplate.postForObject(URL, markup, String.class);
System.out.println("result: " + result);
assertTrue("The document is not valid HTML5: " + markup, result.contains("The document is valid HTML5"));
}
Aggregations