Author: ningjiang
Date: Thu Jul 24 05:00:56 2008
New Revision: 679378

URL: http://svn.apache.org/viewvc?rev=679378&view=rev
Log:
CAMEL-751 Added a unit test of ErrorHandler in spring config

Added:
    
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerTest.java
   (with props)
    
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml
   (with props)
Modified:
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java?rev=679378&r1=679377&r2=679378&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
 Thu Jul 24 05:00:56 2008
@@ -78,9 +78,8 @@
     public void addRoutes(CamelContext context, Collection<Route> routes) 
throws Exception {
         setCamelContext(context);
 
-        if (context instanceof DefaultCamelContext) {
-            DefaultCamelContext defaultCamelContext = (DefaultCamelContext) 
context;
-            ErrorHandlerBuilder handler = 
defaultCamelContext.getErrorHandlerBuilder();
+        if (context instanceof CamelContext) {
+            ErrorHandlerBuilder handler = context.getErrorHandlerBuilder();
             if (handler != null) {
                 setErrorHandlerBuilderIfNull(handler);
             }

Added: 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerTest.java?rev=679378&view=auto
==============================================================================
--- 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerTest.java
 (added)
+++ 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerTest.java
 Thu Jul 24 05:00:56 2008
@@ -0,0 +1,57 @@
+/**
+ * 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.config;
+
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.impl.EventDrivenConsumerRoute;
+import org.apache.camel.processor.DeadLetterChannel;
+import org.apache.camel.processor.RedeliveryPolicy;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ErrorHandlerTest extends SpringTestSupport {
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/spring/errorHandler.xml");
+    }
+
+    public void testEndpointConfiguration() throws Exception {
+        CamelContext context = getMandatoryBean(CamelContext.class, "camel");
+        List<Route> list = context.getRoutes();
+        assertEquals("Number routes created" + list, 1, list.size());
+        for (Route route : list) {
+            Endpoint key = route.getEndpoint();
+            assertEquals("From endpoint", "seda:a", key.getEndpointUri());
+
+            EventDrivenConsumerRoute consumerRoute = 
assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
+            Processor processor = consumerRoute.getProcessor();
+            processor = unwrap(processor);
+
+            DeadLetterChannel deadLetterChannel = 
assertIsInstanceOf(DeadLetterChannel.class, processor);
+
+            RedeliveryPolicy redeliveryPolicy = 
deadLetterChannel.getRedeliveryPolicy();
+
+            assertEquals("getMaximumRedeliveries()", 1, 
redeliveryPolicy.getMaximumRedeliveries());
+            assertEquals("isUseExponentialBackOff()", true, 
redeliveryPolicy.isUseExponentialBackOff());
+        }
+    }
+
+}

Propchange: 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml?rev=679378&view=auto
==============================================================================
--- 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml
 (added)
+++ 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml
 Thu Jul 24 05:00:56 2008
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://activemq.apache.org/camel/schema/spring 
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+
+
+  <camelContext id="camel" errorHandlerRef="deadLetterErrorHandler"
+   xmlns="http://activemq.apache.org/camel/schema/spring";>
+    <route>
+      <from uri="seda:a"/>
+      <to uri="seda:b"/>
+    </route>
+  </camelContext>
+
+  <bean id="deadLetterErrorHandler"
+        class="org.apache.camel.builder.DeadLetterChannelBuilder">
+    <property name="defaultDeadLetterEndpointUri"
+value="bean:exceptionProcessor" />
+    <property name="redeliveryPolicy" ref="rsRedeliveryPolicyConfig" />
+  </bean>
+
+  <bean id="rsRedeliveryPolicyConfig"
+        class="org.apache.camel.processor.RedeliveryPolicy">
+    <property name="maximumRedeliveries" value="1" />
+    <property name="initialRedeliveryDelay" value="30000"/>
+    <property name="useExponentialBackOff" value="true"/>
+  </bean>
+
+</beans>

Propchange: 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to