use of cn.taketoday.http.converter.StringHttpMessageConverter in project today-infrastructure by TAKETODAY.
the class HttpMessageConvertersAutoConfiguration method stringHttpMessageConverter.
@Component
@ConditionalOnMissingBean
public StringHttpMessageConverter stringHttpMessageConverter(Environment environment) {
Charset charset;
String encoding = environment.getProperty("server.encoding");
if (encoding != null) {
charset = Charset.forName(encoding);
} else {
charset = StandardCharsets.UTF_8;
}
StringHttpMessageConverter converter = new StringHttpMessageConverter(charset);
converter.setWriteAcceptCharset(false);
return converter;
}
use of cn.taketoday.http.converter.StringHttpMessageConverter in project today-infrastructure by TAKETODAY.
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 cn.taketoday.http.converter.StringHttpMessageConverter in project today-infrastructure by TAKETODAY.
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 cn.taketoday.http.converter.StringHttpMessageConverter in project today-infrastructure by TAKETODAY.
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 cn.taketoday.http.converter.StringHttpMessageConverter in project today-framework by TAKETODAY.
the class ParameterResolvingRegistryTests method parameterResolvingRegistry.
@Test
void parameterResolvingRegistry() {
assertThat(registry.getMessageConverters()).hasSize(3);
ParameterResolvingRegistry registry1 = new ParameterResolvingRegistry(registry.getMessageConverters());
assertThat(registry1.getMessageConverters()).isNotEmpty().hasSize(3);
assertThat(registry1).isNotEqualTo(registry);
registry.setMessageConverters(List.of(new StringHttpMessageConverter(StandardCharsets.US_ASCII)));
assertThat(registry.getMessageConverters()).isNotEmpty().hasSize(1);
assertThat(registry.toString()).isNotEmpty();
registry.hashCode();
}
Aggregations