}
@Test
public void testCXF4181() throws Exception {
//Try WITH SAAJ
SoapMessage m = new SoapMessage(new MessageImpl());
m.put(Message.HTTP_REQUEST_METHOD, "POST");
m.setVersion(Soap12.getInstance());
XMLStreamReader reader = StaxUtils.createXMLStreamReader(this.getClass()
.getResourceAsStream("cxf4181.xml"));
m.setContent(XMLStreamReader.class, reader);
new SAAJPreInInterceptor().handleMessage(m);
new ReadHeadersInterceptor(null).handleMessage(m);
new StartBodyInterceptor().handleMessage(m);
new SAAJInInterceptor().handleMessage(m);
new Soap12FaultInInterceptor().handleMessage(m);
Node nd = m.getContent(Node.class);
SOAPPart part = (SOAPPart)nd;
assertEquals("S", part.getEnvelope().getPrefix());
assertEquals("S2", part.getEnvelope().getHeader().getPrefix());
assertEquals("S3", part.getEnvelope().getBody().getPrefix());
SOAPFault fault = part.getEnvelope().getBody().getFault();
assertEquals("S", fault.getPrefix());
assertEquals("Authentication Failure", fault.getFaultString());
SoapFault fault2 = (SoapFault)m.getContent(Exception.class);
assertNotNull(fault2);
assertEquals(Soap12.getInstance().getSender(), fault2.getFaultCode());
assertEquals(new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "FailedAuthentication"),
fault2.getSubCode());
Element el = part.getEnvelope().getBody();
nd = el.getFirstChild();
int count = 0;
while (nd != null) {
if (nd instanceof Element) {
count++;
}
nd = nd.getNextSibling();
}
assertEquals(1, count);
//Try WITHOUT SAAJ
m = new SoapMessage(new MessageImpl());
m.setVersion(Soap12.getInstance());
reader = StaxUtils.createXMLStreamReader(this.getClass()
.getResourceAsStream("cxf4181.xml"));
m.setContent(XMLStreamReader.class, reader);