### Question:
XMLFaultOutInterceptor extends AbstractOutDatabindingInterceptor { public void handleMessage(Message message) throws Fault { if (mustPropogateException(message)) { throw (Fault) message.getContent(Exception.class); } Fault f = (Fault) message.getContent(Exception.class); message.put(org.apache.cxf.message.Message.RESPONSE_CODE, f.getStatusCode()); NSStack nsStack = new NSStack(); nsStack.push(); XMLStreamWriter writer = message.getContent(XMLStreamWriter.class); XMLFault xmlFault = XMLFault.createFault(f); try { nsStack.add(XMLConstants.NS_XML_FORMAT); String prefix = nsStack.getPrefix(XMLConstants.NS_XML_FORMAT); StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_ROOT, XMLConstants.NS_XML_FORMAT); StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_STRING, XMLConstants.NS_XML_FORMAT); Throwable t = xmlFault.getCause(); writer.writeCharacters(t == null ? xmlFault.getMessage() : t.toString()); writer.writeEndElement(); if (xmlFault.getDetail() != null) { Element detail = xmlFault.getDetail(); StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_DETAIL, XMLConstants.NS_XML_FORMAT); Node node = detail.getFirstChild(); while (node != null) { StaxUtils.writeNode(node, writer, false); node = node.getNextSibling(); } writer.writeEndElement(); } writer.writeEndElement(); writer.flush(); } catch (XMLStreamException xe) { throw new Fault(new org.apache.cxf.common.i18n.Message("XML_WRITE_EXC", BUNDLE), xe); } } XMLFaultOutInterceptor();  XMLFaultOutInterceptor(String phase); void handleMessage(Message message); @Override void handleFault(Message message);  }### Answer:
@Test public void testFault() throws Exception { FaultDetail detail = new FaultDetail(); detail.setMajor((short)2); detail.setMinor((short)1); PingMeFault fault = new PingMeFault("TEST_FAULT", detail); XMLFault xmlFault = XMLFault.createFault(new Fault(fault)); Element el = xmlFault.getOrCreateDetail(); JAXBContext ctx = JAXBContext.newInstance(FaultDetail.class); Marshaller m = ctx.createMarshaller(); m.marshal(detail, el); OutputStream outputStream = new ByteArrayOutputStream(); xmlMessage.setContent(OutputStream.class, outputStream); XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(outputStream); xmlMessage.setContent(XMLStreamWriter.class, writer); xmlMessage.setContent(Exception.class, xmlFault); out.handleMessage(xmlMessage); outputStream.flush(); XMLStreamReader reader = getXMLReader(); DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader); dxr.nextTag(); StaxUtils.toNextElement(dxr); assertEquals(XMLConstants.NS_XML_FORMAT, dxr.getNamespaceURI()); assertEquals(XMLFault.XML_FAULT_ROOT, dxr.getLocalName()); dxr.nextTag(); StaxUtils.toNextElement(dxr); assertEquals(XMLFault.XML_FAULT_STRING, dxr.getLocalName()); assertEquals(fault.toString(), dxr.getElementText()); dxr.nextTag(); StaxUtils.toNextElement(dxr); assertEquals(XMLFault.XML_FAULT_DETAIL, dxr.getLocalName()); dxr.nextTag(); StaxUtils.toNextElement(dxr); assertEquals("faultDetail", dxr.getLocalName()); }