envelope.serialize(buffer, format);
// envelope.serialize(System.out, format);
String contentType = format.getContentTypeForMTOM("text/xml");
Attachments attachments = new Attachments(new ByteArrayInputStream(buffer.toByteArray()), contentType);
assertEquals(countDataHandlers(bean) + 1, attachments.getAllContentIDs().length);
MTOMStAXSOAPModelBuilder builder = new MTOMStAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(attachments.getRootPartInputStream()), attachments);
OMElement bodyElement = builder.getSOAPEnvelope().getBody().getFirstElement();
assertBeanEquals(expectedResult, ADBBeanUtil.parse(bean.getClass(), cache ? bodyElement.getXMLStreamReader() : bodyElement.getXMLStreamReaderWithoutCaching()));
}