MTOMStAXSOAPModelBuilder builder = createBuilderForTestMTOMMessage();
Attachments attachments = builder.getAttachments();
OMDocument doc = builder.getDocument();
// Find all the binary nodes
List/*<OMText>*/ binaryNodes = new ArrayList();
for (Iterator it = new OMDescendantsIterator(doc.getFirstOMChild()); it.hasNext(); ) {
OMNode node = (OMNode)it.next();
if (node instanceof OMText) {
OMText text = (OMText)node;
if (text.isBinary()) {
binaryNodes.add(text);
}
}
}
assertFalse(binaryNodes.isEmpty());
// At this moment only the SOAP part should have been loaded
assertEquals(1, attachments.getContentIDList().size());
for (Iterator it = binaryNodes.iterator(); it.hasNext(); ) {
// Request the DataHandler and do something with it to make sure
// the part is loaded
((DataHandler)((OMText)it.next()).getDataHandler()).getInputStream().close();
}
assertEquals(binaryNodes.size() + 1, attachments.getContentIDList().size());
}