use of cn.taketoday.http.MockHttpInputMessage in project today-infrastructure by TAKETODAY.
the class StringHttpMessageConverterTests method readJsonApi.
// gh-25328
@Test
public void readJsonApi() throws IOException {
String body = "{\"result\":\"\u0414\u0410\"}";
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
inputMessage.getHeaders().setContentType(new MediaType("application", "vnd.api.v1+json"));
String result = this.converter.read(String.class, inputMessage);
assertThat(result).as("Invalid result").isEqualTo(body);
}
use of cn.taketoday.http.MockHttpInputMessage in project today-infrastructure by TAKETODAY.
the class BufferedImageHttpMessageConverterTests method read.
@Test
public void read() throws IOException {
Resource logo = new ClassPathResource("logo.jpg", BufferedImageHttpMessageConverterTests.class);
byte[] body = FileCopyUtils.copyToByteArray(logo.getInputStream());
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
inputMessage.getHeaders().setContentType(new MediaType("image", "png"));
BufferedImage result = converter.read(BufferedImage.class, inputMessage);
assertThat(result.getHeight()).as("Invalid height").isEqualTo(292);
assertThat(result.getWidth()).as("Invalid width").isEqualTo(819);
}
Aggregations