Author: davsclaus
Date: Mon Jul 7 10:56:17 2008
New Revision: 674567
URL: http://svn.apache.org/viewvc?rev=674567&view=rev
Log:
Added unit test inspired by user forum where an end user can not use spring
bean dead letter channel.
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest.java
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyFailureProcessor.java
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest-context.xml
- copied, changed from r674402,
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerConfigTest-context.xml
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest.java?rev=674567&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest.java
Mon Jul 7 10:56:17 2008
@@ -0,0 +1,53 @@
+/**
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import
org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests;
+
+/**
+ * Unit test that spring configured DeadLetterChannel redelivery policy works.
+ */
[EMAIL PROTECTED]
+public class DeadLetterChannelRedeliveryConfigTest extends
AbstractJUnit38SpringContextTests {
+
+ @Autowired
+ protected ProducerTemplate template;
+
+ @Autowired
+ protected CamelContext context;
+
+ public void testDLCSpringConfiguredRedeliveryPolicy() throws Exception {
+ MockEndpoint dead = context.getEndpoint("mock:dead",
MockEndpoint.class);
+ MockEndpoint result = context.getEndpoint("mock:result",
MockEndpoint.class);
+
+ dead.expectedBodiesReceived("Hello World");
+ dead.message(0).header("org.apache.camel.Redelivered").isEqualTo(true);
+
dead.message(0).header("org.apache.camel.RedeliveryCounter").isEqualTo(3);
+ result.expectedMessageCount(0);
+
+ template.sendBody("direct:in", "Hello World");
+
+ result.assertIsSatisfied();
+ dead.assertIsSatisfied();
+ }
+
+}
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyFailureProcessor.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyFailureProcessor.java?rev=674567&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyFailureProcessor.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/MyFailureProcessor.java
Mon Jul 7 10:56:17 2008
@@ -0,0 +1,31 @@
+/**
+ * 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 org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+
+/**
+ * For unit test.
+ */
+public class MyFailureProcessor implements Processor {
+
+ public void process(Exchange exchange) throws Exception {
+ throw new IllegalArgumentException("Unit test - this is thrown by
intention");
+ }
+
+}
Copied:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest-context.xml
(from r674402,
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerConfigTest-context.xml)
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest-context.xml?p2=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest-context.xml&p1=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerConfigTest-context.xml&r1=674402&r2=674567&rev=674567&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerConfigTest-context.xml
(original)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/DeadLetterChannelRedeliveryConfigTest-context.xml
Mon Jul 7 10:56:17 2008
@@ -18,23 +18,28 @@
<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
- ">
+ 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 xmlns="http://activemq.apache.org/camel/schema/spring"
errorHandlerRef="defaultErrorHandler">
- <template id="myTemplate"/>
+ <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
+ <template id="myTemplate"/>
+ <route errorHandlerRef="myDeadLetterErrorHandler">
+ <from uri="direct:in"/>
+ <process ref="myFailureProcessor"/>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
- <route>
- <from uri="direct:defaultErrorHandler"/>
- <to uri="mock:defaultErrorHandler"/>
- </route>
- <route errorHandlerRef="customErrorHandler">
- <from uri="direct:customErrorHandler"/>
- <to uri="mock:customErrorHandler"/>
- </route>
- </camelContext>
+ <bean id="myDeadLetterErrorHandler"
class="org.apache.camel.builder.DeadLetterChannelBuilder">
+ <property name="defaultDeadLetterEndpointUri" value="mock:dead"/>
+ <property name="redeliveryPolicy" ref="myRedeliveryPolicyConfig"/>
+ </bean>
+
+ <bean id="myFailureProcessor"
class="org.apache.camel.spring.config.MyFailureProcessor"/>
+
+ <bean id="myRedeliveryPolicyConfig"
class="org.apache.camel.processor.RedeliveryPolicy">
+ <property name="maximumRedeliveries" value="3"/>
+ <property name="initialRedeliveryDelay" value="250"/>
+ </bean>
- <bean id="defaultErrorHandler"
class="org.apache.camel.spring.config.DummyErrorHandlerBuilder"/>
- <bean id="customErrorHandler"
class="org.apache.camel.spring.config.DummyErrorHandlerBuilder"/>
</beans>