Search in sources :

Example 6 with DifferenceEvaluator

use of org.xmlunit.diff.DifferenceEvaluator in project spring-framework by spring-projects.

the class Jaxb2RootElementHttpMessageConverterTests method writeXmlRootElementSubclass.

@Test
public void writeXmlRootElementSubclass() throws Exception {
    MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
    converter.write(rootElementCglib, null, outputMessage);
    assertEquals("Invalid content-type", new MediaType("application", "xml"), outputMessage.getHeaders().getContentType());
    DifferenceEvaluator ev = chain(Default, downgradeDifferencesToEqual(XML_STANDALONE));
    assertThat("Invalid result", outputMessage.getBodyAsString(StandardCharsets.UTF_8), isSimilarTo("<rootElement><type s=\"Hello World\"/></rootElement>").withDifferenceEvaluator(ev));
}
Also used : MockHttpOutputMessage(org.springframework.http.MockHttpOutputMessage) MediaType(org.springframework.http.MediaType) DifferenceEvaluator(org.xmlunit.diff.DifferenceEvaluator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 DifferenceEvaluator (org.xmlunit.diff.DifferenceEvaluator)6 MockHttpOutputMessage (org.springframework.http.MockHttpOutputMessage)3 StringWriter (java.io.StringWriter)2 StreamResult (javax.xml.transform.stream.StreamResult)2 MediaType (org.springframework.http.MediaType)2 Result (javax.xml.transform.Result)1 SAXResult (javax.xml.transform.sax.SAXResult)1