protected void runTest() throws Throwable {
// Prepare the message. Note that we do this programmatically to make sure that the message
// doesn't contain any unwanted whitespace.
SOAPFactory factory = spec.getFactory(metaFactory);
SOAPEnvelope orgEnvelope = factory.getDefaultEnvelope();
orgEnvelope.getBody().addChild(soapFactory.createOMElement(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix()));
String message = orgEnvelope.toString();
SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(message)).getSOAPEnvelope();
assertEquals(qname.getLocalPart(), envelope.getSOAPBodyFirstElementLocalName());
OMNamespace ns = envelope.getSOAPBodyFirstElementNS();
if (qname.getNamespaceURI().length() == 0) {
assertNull(ns);
} else {
assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
assertEquals(qname.getPrefix(), ns.getPrefix());
}
// Also request an XMLStreamReader. The LLOM implementation triggers some special processing
// in this case (because the getSOAPBodyFirstElementXXX calls put the builder in lookahead
// mode). This is a regression test for r631687 (AXIOM-282).
XMLStreamReader reader = envelope.getXMLStreamReader(false);
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals("Envelope", reader.getLocalName());
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
assertEquals("Body", reader.getLocalName());
assertEquals(XMLStreamReader.START_ELEMENT, reader.next());