Search in sources :

Example 56 with MockHttpInputMessage

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

the class Jaxb2RootElementHttpMessageConverterTests method readXmlRootElement.

@Test
public void readXmlRootElement() throws Exception {
    byte[] body = "<rootElement><type s=\"Hello World\"/></rootElement>".getBytes("UTF-8");
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
    RootElement result = (RootElement) converter.read(RootElement.class, inputMessage);
    assertEquals("Invalid result", "Hello World", result.type.s);
}
Also used : MockHttpInputMessage(org.springframework.http.MockHttpInputMessage) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)56 MockHttpInputMessage (org.springframework.http.MockHttpInputMessage)56 MediaType (org.springframework.http.MediaType)31 ClassPathResource (org.springframework.core.io.ClassPathResource)8 XmlRootElement (javax.xml.bind.annotation.XmlRootElement)7 Resource (org.springframework.core.io.Resource)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 InputStream (java.io.InputStream)4 StreamSource (javax.xml.transform.stream.StreamSource)4 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 SAXSource (javax.xml.transform.sax.SAXSource)3 StAXSource (javax.xml.transform.stax.StAXSource)3 Unmarshaller (org.springframework.oxm.Unmarshaller)3 InputSource (org.xml.sax.InputSource)3 Message (com.google.protobuf.Message)2 InputStreamReader (java.io.InputStreamReader)2 Type (java.lang.reflect.Type)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2