Return-Path: Delivered-To: apmail-camel-commits-archive@www.apache.org Received: (qmail 864 invoked from network); 6 Nov 2009 13:02:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Nov 2009 13:02:46 -0000 Received: (qmail 79148 invoked by uid 500); 6 Nov 2009 13:02:45 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 79099 invoked by uid 500); 6 Nov 2009 13:02:45 -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 79090 invoked by uid 99); 6 Nov 2009 13:02:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Nov 2009 13:02:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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; Fri, 06 Nov 2009 13:02:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 08BEE23888C2; Fri, 6 Nov 2009 13:02:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r833381 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/transport/CamelDestination.java test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java Date: Fri, 06 Nov 2009 13:02:21 -0000 To: commits@camel.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091106130222.08BEE23888C2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ningjiang Date: Fri Nov 6 13:02:21 2009 New Revision: 833381 URL: http://svn.apache.org/viewvc?rev=833381&view=rev Log: CAMEL-2142 added unit test for checkException Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java?rev=833381&r1=833380&r2=833381&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java (original) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java Fri Nov 6 13:02:21 2009 @@ -86,6 +86,13 @@ return LOG; } + public void setCheckException(boolean exception) { + checkException = exception; + } + + public boolean isCheckException() { + return checkException; + } /** * @param inMessage the incoming message * @return the inbuilt backchannel Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java?rev=833381&r1=833380&r2=833381&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java (original) +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java Fri Nov 6 13:02:21 2009 @@ -23,7 +23,9 @@ import javax.xml.namespace.QName; import org.apache.camel.CamelContext; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.DefaultCamelContext; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; @@ -46,6 +48,7 @@ protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { + onException(RuntimeCamelException.class).handled(true).to("mock:error"); from("direct:Producer").to("direct:EndpointA"); } }; @@ -136,7 +139,7 @@ String reponse = new String(bytes); assertEquals("The reponse date should be equals", content, reponse); } - + @Test public void testRoundTripDestination() throws Exception { @@ -170,6 +173,8 @@ } } }; + MockEndpoint error = (MockEndpoint)context.getEndpoint("mock:error"); + error.expectedMessageCount(0); //this call will active the camelDestination destination.setMessageObserver(observer); // set is oneway false for get response from destination @@ -179,7 +184,60 @@ // create the thread to handler the Destination incomming message verifyReceivedMessage(inMessage, "HelloWorld Response"); + error.assertIsSatisfied(); + destination.shutdown(); + } + + @Test + public void testRoundTripDestinationWithFault() throws Exception { + + inMessage = null; + EndpointInfo conduitEpInfo = new EndpointInfo(); + conduitEpInfo.setAddress("camel://direct:Producer"); + // set up the conduit send to be true + CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false); + final Message outMessage = new MessageImpl(); + + endpointInfo.setAddress("camel://direct:EndpointA"); + final CamelDestination destination = setupCamelDestination(endpointInfo, true); + destination.setCheckException(true); + + // set up MessageObserver for handlering the conduit message + MessageObserver observer = new MessageObserver() { + public void onMessage(Message m) { + try { + Exchange exchange = new ExchangeImpl(); + exchange.setInMessage(m); + m.setExchange(exchange); + verifyReceivedMessage(m, "HelloWorld"); + //verifyHeaders(m, outMessage); + // setup the message for + Conduit backConduit; + backConduit = destination.getBackChannel(m, null, null); + // wait for the message to be got from the conduit + Message replyMessage = new MessageImpl(); + replyMessage.setContent(Exception.class, new RuntimeCamelException()); + sendoutMessage(backConduit, replyMessage, true, "HelloWorld Fault"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + + MockEndpoint error = (MockEndpoint)context.getEndpoint("mock:error"); + error.expectedMessageCount(1); + + //this call will active the camelDestination + destination.setMessageObserver(observer); + // set is oneway false for get response from destination + // need to use another thread to send the request message + sendoutMessage(conduit, outMessage, false, "HelloWorld"); + // wait for the message to be got from the destination, + // create the thread to handler the Destination incomming message + verifyReceivedMessage(inMessage, "HelloWorld Fault"); + error.assertIsSatisfied(); + destination.shutdown(); }