@Test
public void writesDOMSourceToOutputStream() throws Exception {

    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(TEST_XML_CONTENT_BYTES));
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    domSourceEntityProvider.writeTo(new DOMSource(document), DOMSource.class, null, null, APPLICATION_XML_TYPE, null, out);
    Document serializedDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(out.toByteArray()));
    assertThatXmlDocumentContainsAllExpectedNodes(serializedDocument);
}