Return-Path: Delivered-To: apmail-activemq-camel-commits-archive@locus.apache.org Received: (qmail 10967 invoked from network); 6 Jan 2009 16:46:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jan 2009 16:46:24 -0000 Received: (qmail 11336 invoked by uid 500); 6 Jan 2009 16:46:24 -0000 Delivered-To: apmail-activemq-camel-commits-archive@activemq.apache.org Received: (qmail 11318 invoked by uid 500); 6 Jan 2009 16:46:24 -0000 Mailing-List: contact camel-commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-dev@activemq.apache.org Delivered-To: mailing list camel-commits@activemq.apache.org Received: (qmail 11309 invoked by uid 99); 6 Jan 2009 16:46:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Jan 2009 08:46:24 -0800 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; Tue, 06 Jan 2009 16:46:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5C44D238889C; Tue, 6 Jan 2009 08:45:57 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r731998 - in /activemq/camel/trunk/components/camel-spring/src/test: java/org/apache/camel/spring/processor/onexception/SpringOnExceptionSubRouteTest.java resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml Date: Tue, 06 Jan 2009 16:45:57 -0000 To: camel-commits@activemq.apache.org From: janstey@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090106164557.5C44D238889C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: janstey Date: Tue Jan 6 08:45:56 2009 New Revision: 731998 URL: http://svn.apache.org/viewvc?rev=731998&view=rev Log: CAMEL-1218 - Add test for an exception clause within a route Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionSubRouteTest.java (with props) activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml (with props) Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionSubRouteTest.java URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionSubRouteTest.java?rev=731998&view=auto ============================================================================== --- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionSubRouteTest.java (added) +++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionSubRouteTest.java Tue Jan 6 08:45:56 2009 @@ -0,0 +1,79 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring.processor.onexception; + +import org.apache.camel.CamelContext; +import org.apache.camel.ContextTestSupport; +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.mock.MockEndpoint; + +import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext; + +/** + * Unit test for onException with the spring DSL. + */ +public class SpringOnExceptionSubRouteTest extends ContextTestSupport { + + public void testOrderOk() throws Exception { + MockEndpoint result = getMockEndpoint("mock:result"); + result.expectedBodiesReceived("Order OK"); + result.expectedHeaderReceived("orderid", "123"); + + MockEndpoint error = getMockEndpoint("mock:error"); + error.expectedMessageCount(0); + + Object out = template.requestBodyAndHeader("direct:start", "Order: MacBook Pro", "customerid", "444"); + assertEquals("Order OK", out); + + assertMockEndpointsSatisfied(); + } + + public void testOrderError() throws Exception { + MockEndpoint error = getMockEndpoint("mock:error"); + error.expectedBodiesReceived("Order ERROR"); + error.expectedHeaderReceived("orderid", "failed"); + + MockEndpoint result = getMockEndpoint("mock:result"); + result.expectedMessageCount(0); + + Object out = template.requestBodyAndHeader("direct:start", "Order: kaboom", "customerid", "555"); + assertEquals("Order ERROR", out); + + assertMockEndpointsSatisfied(); + } + + public void testOrderErrorWithNoExceptionClause() throws Exception { + MockEndpoint error = getMockEndpoint("mock:error"); + error.expectedMessageCount(0); + + MockEndpoint result = getMockEndpoint("mock:result"); + result.expectedMessageCount(0); + + try { + template.requestBodyAndHeader("direct:start_with_no_handler", "Order: kaboom", "customerid", "555"); + fail("Should throw an Exception"); + } catch (Exception e) { + assertEquals("Cannot order: kaboom", e.getCause().getMessage()); + } + + assertMockEndpointsSatisfied(); + } + + protected CamelContext createCamelContext() throws Exception { + return createSpringCamelContext(this, "/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml"); + } +} \ No newline at end of file Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/onexception/SpringOnExceptionSubRouteTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml?rev=731998&view=auto ============================================================================== --- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml (added) +++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml Tue Jan 6 08:45:56 2009 @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + org.apache.camel.spring.processor.onexception.OrderFailedException + + + true + + + + + + + + + + + + + + + + + + + Propchange: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/onExceptionSubRouteTest.xml ------------------------------------------------------------------------------ svn:eol-style = native