You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2009/11/06 13:22:31 UTC

svn commit: r833371 - in /servicemix/components/engines/servicemix-camel/trunk/src/test: java/org/apache/servicemix/camel/ resources/org/apache/servicemix/camel/su12-src/

Author: gertv
Date: Fri Nov  6 12:22:31 2009
New Revision: 833371

URL: http://svn.apache.org/viewvc?rev=833371&view=rev
Log:
SMXCOMP-651: Adding a test for error handling with a RobustInOnly MEP

Added:
    servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/JbiRobustInOnlyWithFaultHandledTrueSpringDSLTest.java
    servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su12-src/
    servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su12-src/camel-context.xml

Added: servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/JbiRobustInOnlyWithFaultHandledTrueSpringDSLTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/JbiRobustInOnlyWithFaultHandledTrueSpringDSLTest.java?rev=833371&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/JbiRobustInOnlyWithFaultHandledTrueSpringDSLTest.java (added)
+++ servicemix/components/engines/servicemix-camel/trunk/src/test/java/org/apache/servicemix/camel/JbiRobustInOnlyWithFaultHandledTrueSpringDSLTest.java Fri Nov  6 12:22:31 2009
@@ -0,0 +1,29 @@
+/*
+ * 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.servicemix.camel;
+
+
+/**
+ * Tests on handling fault messages with the Camel Exception handler
+ */
+public class JbiRobustInOnlyWithFaultHandledTrueSpringDSLTest extends JbiInOnlyWithFaultHandledTrueSpringDSLTest {
+
+    @Override
+    protected String getServiceUnitName() {
+        return "su12";
+    }
+}

Added: servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su12-src/camel-context.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su12-src/camel-context.xml?rev=833371&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su12-src/camel-context.xml (added)
+++ servicemix/components/engines/servicemix-camel/trunk/src/test/resources/org/apache/servicemix/camel/su12-src/camel-context.xml Fri Nov  6 12:22:31 2009
@@ -0,0 +1,74 @@
+<?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.
+
+-->
+<!-- START SNIPPET: camel -->
+<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.0.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext  xmlns="http://camel.apache.org/schema/spring">
+    <route streamCache="true" handleFault="true" errorHandlerRef="deadLetterErrorHandler">
+      <from uri="jbi:service:urn:test:fault-handled-true"/>
+      <onException>
+        <!-- Catch exception from in-only/robust-in-only message exchange. -->
+        <exception>org.apache.servicemix.jbi.exception.FaultException</exception>
+        <redeliveryPolicy maximumRedeliveries="0"/>
+        <handled>
+          <constant>true</constant>
+        </handled>
+        <to uri="jbi:service:urn:test:receiver-service"/>
+      </onException>
+      <onException>
+        <!-- This clause is needed for testing since the test client still
+             throws the older org.apache.servicemix.jbi.FaultException. You 
+             only need to catch org.apache.servicemix.jbi.exception.FaultException 
+             in runtime scenarios.
+             
+             TODO remove this when ServiceMix 3.3.1 is released.
+             -->
+        <exception>org.apache.servicemix.jbi.FaultException</exception>
+        <redeliveryPolicy maximumRedeliveries="0"/>
+        <handled>
+          <constant>true</constant>
+        </handled>
+        <to uri="jbi:service:urn:test:receiver-service"/>
+      </onException>     
+      <to uri="jbi:service:urn:test:faulty-service?mep=robust-in-only"/>
+    </route>
+  </camelContext>
+
+  <bean id="deadLetterErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
+    <property name="logger" ref="logger" />
+    <property name="deadLetterUri" value="log:dlc?showBody=false,log:dlc"/>
+    <property name="redeliveryPolicy" ref="redeliveryPolicyConfig" />
+  </bean>
+    
+  <bean id="redeliveryPolicyConfig" class="org.apache.camel.processor.RedeliveryPolicy">
+    <property name="maximumRedeliveries" value="0" />
+    <property name="redeliverDelay" value="2000" />
+    <property name="useExponentialBackOff" value="true" />
+    <property name="backOffMultiplier" value="2" />
+  </bean>
+
+  <bean id="logger" class="org.apache.camel.processor.Logger" />
+
+</beans>