Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 89309 invoked from network); 3 Nov 2006 06:41:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Nov 2006 06:41:44 -0000 Received: (qmail 62686 invoked by uid 500); 3 Nov 2006 06:41:55 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 62618 invoked by uid 500); 3 Nov 2006 06:41:55 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 62606 invoked by uid 99); 3 Nov 2006 06:41:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Nov 2006 22:41:55 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Nov 2006 22:41:43 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id A64D21A9846; Thu, 2 Nov 2006 22:41:18 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r470688 - in /incubator/cxf/trunk: rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLWrapTest.java Date: Fri, 03 Nov 2006 06:41:18 -0000 To: cxf-commits@incubator.apache.org From: tli@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061103064118.A64D21A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tli Date: Thu Nov 2 22:41:17 2006 New Revision: 470688 URL: http://svn.apache.org/viewvc?view=rev&rev=470688 Log: CXF-196 applied Ajay's patch and modify xml wrap systest to include this scenario Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLWrapTest.java Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java?view=diff&rev=470688&r1=470687&r2=470688 ============================================================================== --- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java (original) +++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLFaultOutInterceptor.java Thu Nov 2 22:41:17 2006 @@ -59,19 +59,17 @@ 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(); + 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()); // fault string writer.writeEndElement(); - // call data writer to marshal exception BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class); - if (bop != null) { + if (t != null && bop != null) { if (!bop.isUnwrappedCapable()) { bop = bop.getUnwrappedOperation(); } @@ -81,11 +79,15 @@ FaultInfo fi = it.next(); for (MessagePartInfo mpi : fi.getMessageParts()) { Class cls = mpi.getTypeClass(); - Method method = t.getClass().getMethod("getFaultInfo", new Class[0]); - Class sub = method.getReturnType(); - if (cls != null && cls.equals(sub)) { - part = mpi; - break; + try { + Method method = t.getClass().getMethod("getFaultInfo", new Class[0]); + Class sub = method.getReturnType(); + if (cls != null && cls.equals(sub)) { + part = mpi; + break; + } + } catch (NoSuchMethodException ne) { + // Ignore as it is not a User Defined Fault. } } } @@ -96,18 +98,13 @@ dataWriter.write(getFaultInfo(t), part, message); writer.writeEndElement(); } - } + } // fault root writer.writeEndElement(); - writer.flush(); - - } catch (NoSuchMethodException ne) { - throw new Fault(new org.apache.cxf.common.i18n.Message("UNKNOWN_EXCEPTION", BUNDLE), ne); } catch (XMLStreamException xe) { throw new Fault(new org.apache.cxf.common.i18n.Message("XML_WRITE_EXC", BUNDLE), xe); } - } private static Object getFaultInfo(Throwable fault) { @@ -119,7 +116,6 @@ } catch (Exception ex) { throw new RuntimeException("Could not get faultInfo out of Exception", ex); } - return null; } } Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLWrapTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLWrapTest.java?view=diff&rev=470688&r1=470687&r2=470688 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLWrapTest.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerXMLWrapTest.java Thu Nov 2 22:41:17 2006 @@ -35,6 +35,7 @@ import org.apache.cxf.systest.common.ClientServerSetupBase; import org.apache.cxf.systest.common.TestServerBase; import org.apache.hello_world_xml_http.wrapped.Greeter; +import org.apache.hello_world_xml_http.wrapped.GreeterFaultImpl; import org.apache.hello_world_xml_http.wrapped.GreeterImpl; import org.apache.hello_world_xml_http.wrapped.PingMeFault; import org.apache.hello_world_xml_http.wrapped.XMLService; @@ -55,6 +56,10 @@ Object implementor = new GreeterImpl(); String address = "http://localhost:9032/XMLService/XMLPort"; Endpoint.publish(address, implementor); + + Object faultImplementor = new GreeterFaultImpl(); + String faultAddress = "http://localhost:9033/XMLService/XMLFaultPort"; + Endpoint.publish(faultAddress, faultImplementor); } public static void main(String[] args) { @@ -116,7 +121,7 @@ String response1 = new String("Hello "); String response2 = new String("Bonjour"); Greeter greeter = service.getPort(fakePortName, Greeter.class); - try { + try { String username = System.getProperty("user.name"); String reply = greeter.greetMe(username); @@ -132,10 +137,10 @@ } catch (UndeclaredThrowableException ex) { throw (Exception) ex.getCause(); } - BindingProvider bp = (BindingProvider)greeter; + BindingProvider bp = (BindingProvider) greeter; Map responseContext = bp.getResponseContext(); - Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE); - assertEquals(200, responseCode.intValue()); + Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE); + assertEquals(200, responseCode.intValue()); } public void testXMLFault() throws Exception { @@ -143,19 +148,28 @@ this.getClass().getResource("/wsdl/hello_world_xml_wrapped.wsdl"), serviceName); assertNotNull(service); Greeter greeter = service.getPort(portName, Greeter.class); - try { + try { greeter.pingMe(); fail("did not catch expected PingMeFault exception"); } catch (PingMeFault ex) { assertEquals("minor value", 1, ex.getFaultInfo().getMinor()); assertEquals("major value", 2, ex.getFaultInfo().getMajor()); - - BindingProvider bp = (BindingProvider)greeter; + + BindingProvider bp = (BindingProvider) greeter; Map responseContext = bp.getResponseContext(); String contentType = (String) responseContext.get(Message.CONTENT_TYPE); assertEquals("text/xml", contentType); Integer responseCode = (Integer) responseContext.get(Message.RESPONSE_CODE); - assertEquals(500, responseCode.intValue()); + assertEquals(500, responseCode.intValue()); + } + + Greeter greeterFault = service.getXMLFaultPort(); + try { + greeterFault.pingMe(); + fail("did not catch expected runtime exception"); + } catch (Exception ex) { + assertTrue("check expected message of exception", ex.getMessage().indexOf( + GreeterFaultImpl.RUNTIME_EXCEPTION_MESSAGE) >= 0); } } }