use of org.apache.cxf.interceptor.ClientFaultConverter in project cxf by apache.
the class XMLFaultInterceptorsTest method testRuntimeExceptionOfImpl.
@Test
public void testRuntimeExceptionOfImpl() throws Exception {
String ns = "http://apache.org/hello_world_xml_http/wrapped";
common("/wsdl/hello_world_xml_wrapped.wsdl", new QName(ns, "XMLPort"), MyComplexStructType.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
xmlMessage.setContent(OutputStream.class, baos);
xmlMessage.setContent(XMLStreamWriter.class, StaxUtils.createXMLStreamWriter(baos));
xmlMessage.setContent(Exception.class, new Fault(new RuntimeException("dummy exception")));
XMLFaultOutInterceptor xfo = new XMLFaultOutInterceptor("phase1");
chain.add(xfo);
InHelpInterceptor ih = new InHelpInterceptor("phase2");
ClientFaultConverter cfc = new ClientFaultConverter("phase3");
XMLFaultInInterceptor xfi = new XMLFaultInInterceptor("phase3");
chain.add(ih);
chain.add(cfc);
chain.add(xfi);
chain.doIntercept(xmlMessage);
assertNotNull(xmlMessage.getContent(Exception.class));
assertTrue(xmlMessage.getContent(Exception.class) instanceof XMLFault);
XMLFault xfault = (XMLFault) xmlMessage.getContent(Exception.class);
assertTrue("check message expected - dummy exception", xfault.getMessage().indexOf("dummy exception") >= 0);
}
Aggregations