Search in sources :

Example 76 with MockHttpInputMessage

use of org.springframework.http.MockHttpInputMessage in project spring-framework by spring-projects.

the class ByteArrayHttpMessageConverterTests method read.

@Test
public void read() throws IOException {
    byte[] body = new byte[] { 0x1, 0x2 };
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
    inputMessage.getHeaders().setContentType(new MediaType("application", "octet-stream"));
    byte[] result = converter.read(byte[].class, inputMessage);
    assertThat(result).as("Invalid result").isEqualTo(body);
}
Also used : MockHttpInputMessage(org.springframework.http.MockHttpInputMessage) MediaType(org.springframework.http.MediaType) Test(org.junit.jupiter.api.Test)

Aggregations

MockHttpInputMessage (org.springframework.http.MockHttpInputMessage)76 Test (org.junit.jupiter.api.Test)65 MediaType (org.springframework.http.MediaType)31 ArrayList (java.util.ArrayList)16 List (java.util.List)15 MockHttpOutputMessage (org.springframework.http.MockHttpOutputMessage)13 Test (org.junit.Test)11 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)8 ClassPathResource (org.springframework.core.io.ClassPathResource)8 Resource (org.springframework.core.io.Resource)7 HttpMessageNotReadableException (org.springframework.http.converter.HttpMessageNotReadableException)7 Type (java.lang.reflect.Type)5 HashMap (java.util.HashMap)5 Message (com.google.protobuf.Message)4 InputStream (java.io.InputStream)4 XmlRootElement (javax.xml.bind.annotation.XmlRootElement)4 StreamSource (javax.xml.transform.stream.StreamSource)4 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)4 XmlRootElement (jakarta.xml.bind.annotation.XmlRootElement)3 Charset (java.nio.charset.Charset)3