You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/06/02 11:36:28 UTC
svn commit: r950456 -
/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java
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 {