* OMText nodes.
*
* @throws Exception
*/
public void testDeferredLoadingOfAttachments() throws Exception {
Attachments attachments = createAttachmentsForTestMTOMMessage();
SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(attachments);
OMDocument doc = builder.getDocument();
// Find all the binary nodes
List/*<OMText>*/ binaryNodes = new ArrayList();
for (Iterator it = doc.getDescendants(false); 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());
}