Return-Path: Delivered-To: apmail-camel-commits-archive@www.apache.org Received: (qmail 71045 invoked from network); 2 Jun 2010 09:36:50 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jun 2010 09:36:50 -0000 Received: (qmail 87165 invoked by uid 500); 2 Jun 2010 09:36:50 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 87114 invoked by uid 500); 2 Jun 2010 09:36:50 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 87107 invoked by uid 99); 2 Jun 2010 09:36:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 09:36:50 +0000 X-ASF-Spam-Status: No, hits=-1570.0 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 09:36:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0BE8E23888FE; Wed, 2 Jun 2010 09:36:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r950456 - /camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java Date: Wed, 02 Jun 2010 09:36:28 -0000 To: commits@camel.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100602093629.0BE8E23888FE@eris.apache.org> Author: ningjiang Date: Wed Jun 2 09:36:28 2010 New Revision: 950456 URL: http://svn.apache.org/viewvc?rev=950456&view=rev Log: Added a unit test of cxf fault which is based on the user forum Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java?rev=950456&r1=950455&r2=950456&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java (original) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java Wed Jun 2 09:36:28 2010 @@ -27,7 +27,10 @@ import org.w3c.dom.Element; import org.w3c.dom.Text; import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.test.junit4.CamelTestSupport; import org.apache.camel.util.IOHelper; @@ -79,6 +82,23 @@ public class CxfCustomizedExceptionTest protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { + // START SNIPPET: onException + from("direct:start") + .onException(SoapFault.class) + .maximumRedeliveries(0) + .handled(true) + .process(new Processor() { + public void process(Exchange exchange) throws Exception { + SoapFault fault = + exchange.getProperty(Exchange.EXCEPTION_CAUGHT, SoapFault.class); + exchange.getOut().setBody(fault.getDetail().getTextContent()); + } + + }) + .to("mock:error") + .end() + .to(routerEndpointURI); + // END SNIPPET: onException // START SNIPPET: ThrowFault from(routerEndpointURI).setFaultBody(constant(SOAP_FAULT)); // END SNIPPET: ThrowFault @@ -90,6 +110,14 @@ public class CxfCustomizedExceptionTest protected CamelContext createCamelContext() throws Exception { return new DefaultCamelContext(); } + + @Test + public void testInvokingServiceFromCamel() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:error"); + mock.expectedBodiesReceived(DETAIL_TEXT); + template.sendBodyAndHeader("direct:start", "hello world" , CxfConstants.OPERATION_NAME, "echo"); + mock.assertIsSatisfied(); + } @Test public void testInvokingServiceFromCXFClient() throws Exception {