use of cn.taketoday.http.converter.ResourceHttpMessageConverter in project today-infrastructure by TAKETODAY.
the class RestTemplateBuilderTests method messageConvertersShouldReplaceExisting.
@Test
void messageConvertersShouldReplaceExisting() {
RestTemplate template = this.builder.messageConverters(new ResourceHttpMessageConverter()).messageConverters(Collections.singleton(this.messageConverter)).build();
assertThat(template.getMessageConverters()).containsOnly(this.messageConverter);
}
use of cn.taketoday.http.converter.ResourceHttpMessageConverter in project today-infrastructure by TAKETODAY.
the class RestTemplateBuilderTests method additionalMessageConvertersShouldAddToExisting.
@Test
void additionalMessageConvertersShouldAddToExisting() {
HttpMessageConverter<?> resourceConverter = new ResourceHttpMessageConverter();
RestTemplate template = this.builder.messageConverters(resourceConverter).additionalMessageConverters(this.messageConverter).build();
assertThat(template.getMessageConverters()).containsOnly(resourceConverter, this.messageConverter);
}
use of cn.taketoday.http.converter.ResourceHttpMessageConverter in project today-framework by TAKETODAY.
the class RestTemplateBuilderTests method additionalMessageConvertersShouldAddToExisting.
@Test
void additionalMessageConvertersShouldAddToExisting() {
HttpMessageConverter<?> resourceConverter = new ResourceHttpMessageConverter();
RestTemplate template = this.builder.messageConverters(resourceConverter).additionalMessageConverters(this.messageConverter).build();
assertThat(template.getMessageConverters()).containsOnly(resourceConverter, this.messageConverter);
}
use of cn.taketoday.http.converter.ResourceHttpMessageConverter in project today-framework by TAKETODAY.
the class RequestResponseBodyMethodProcessorTests method handleReturnValueImage.
// SPR-12894
@Test
public void handleReturnValueImage() throws Throwable {
this.servletRequest.addHeader("Accept", "*/*");
Method method = getClass().getDeclaredMethod("getImage");
MethodParameter returnType = new MethodParameter(method, -1);
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new ResourceHttpMessageConverter());
RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters);
ClassPathResource resource = new ClassPathResource("logo.jpg", getClass());
processor.writeWithMessageConverters(resource, returnType, this.request);
assertThat(this.servletResponse.getHeader("Content-Type")).isEqualTo("image/jpeg");
}
use of cn.taketoday.http.converter.ResourceHttpMessageConverter in project today-framework by TAKETODAY.
the class RestTemplateBuilderTests method messageConvertersShouldReplaceExisting.
@Test
void messageConvertersShouldReplaceExisting() {
RestTemplate template = this.builder.messageConverters(new ResourceHttpMessageConverter()).messageConverters(Collections.singleton(this.messageConverter)).build();
assertThat(template.getMessageConverters()).containsOnly(this.messageConverter);
}
Aggregations