String messageText = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+ "<soap:Header>"
+ ""
+ "</soap:Header> "
+ "<soap:Body> "
+ " <soap:Fault>"
+ " <faultcode>" + FAULT_CODE + "</faultcode>"
+ " <faultstring>" + FAULT_STRING + "</faultstring>"
+ " <detail><d1>" + DETAIL_ENTRY_TEXT + "</d1></detail>"
+ " </soap:Fault>"
+ "</soap:Body>"
+ "</soap:Envelope>";
AxisServer server = new AxisServer();
Message message = new Message(messageText);
message.setMessageContext(new MessageContext(server));
SOAPEnvelope envelope = (SOAPEnvelope) message.getSOAPEnvelope();
assertNotNull("envelope", envelope);
SOAPBodyElement respBody = envelope.getFirstBody();
assertTrue("respBody should be a SOAPFaultElement", respBody
instanceof SOAPFault);
AxisFault aFault = ((SOAPFault) respBody).getFault();
assertNotNull("Fault should not be null", aFault);
QName faultCode = aFault.getFaultCode();
assertNotNull("faultCode should not be null", faultCode);
assertEquals("faultCode should match",
faultCode.getLocalPart(),
"Some.FaultCode");
String faultString = aFault.getFaultString();
assertNotNull("faultString should not be null", faultString);
assertEquals("faultString should match", faultString,
FAULT_STRING);
Element [] details = aFault.getFaultDetails();
assertNotNull("faultDetails should not be null", details);
assertEquals("details should have exactly one element", details.length,
1);
Element el = details[0];
assertEquals("detail entry tag name should match",
el.getLocalName(), "d1");
Text text = (Text)el.getFirstChild();
assertEquals("detail entry string should match",
text.getData(), DETAIL_ENTRY_TEXT);