camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-9124: RedeliveryPattern should support property placeholders.
Date Wed, 09 Sep 2015 12:32:30 GMT
CAMEL-9124: RedeliveryPattern should support property placeholders.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ab88e645
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ab88e645
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ab88e645

Branch: refs/heads/camel-2.15.x
Commit: ab88e6451ff38d4415e1ccb653b3950c26c78e91
Parents: 63234bd
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Sep 9 14:32:26 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Sep 9 14:32:53 2015 +0200

----------------------------------------------------------------------
 .../camel/model/RedeliveryPolicyDefinition.java |  4 +-
 ...iesComponentOnExceptionDelayPatternTest.java | 65 ++++++++++++++++++++
 .../properties/myproperties.properties          |  2 +
 3 files changed, 69 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ab88e645/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
b/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
index f61e91f..5e9f145 100644
--- a/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
@@ -156,13 +156,13 @@ public class RedeliveryPolicyDefinition {
                 }
             }
             if (delayPattern != null) {
-                answer.setDelayPattern(delayPattern);
+                answer.setDelayPattern(CamelContextHelper.parseText(context, delayPattern));
             }
             if (allowRedeliveryWhileStopping != null) {
                 answer.setAllowRedeliveryWhileStopping(CamelContextHelper.parseBoolean(context,
allowRedeliveryWhileStopping));
             }
             if (exchangeFormatterRef != null) {
-                answer.setExchangeFormatterRef(exchangeFormatterRef);
+                answer.setExchangeFormatterRef(CamelContextHelper.parseText(context, exchangeFormatterRef));
             }
         } catch (Exception e) {
             throw ObjectHelper.wrapRuntimeCamelException(e);

http://git-wip-us.apache.org/repos/asf/camel/blob/ab88e645/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentOnExceptionDelayPatternTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentOnExceptionDelayPatternTest.java
b/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentOnExceptionDelayPatternTest.java
new file mode 100644
index 0000000..b812f77
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/properties/PropertiesComponentOnExceptionDelayPatternTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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.component.properties;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version 
+ */
+public class PropertiesComponentOnExceptionDelayPatternTest extends ContextTestSupport {
+
+    public void testDelayPattern() throws Exception {
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(Exception.class)
+                    .delayPattern("{{myDelayPattern}}")
+                    .maximumRedeliveries(1)
+                    .handled(true)
+                    .to("mock:dead");
+
+                from("direct:start")
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        };
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+
+        PropertiesComponent pc = new PropertiesComponent();
+        pc.setCamelContext(context);
+        pc.setLocations(new String[]{"classpath:org/apache/camel/component/properties/myproperties.properties"});
+        context.addComponent("properties", pc);
+
+        return context;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ab88e645/camel-core/src/test/resources/org/apache/camel/component/properties/myproperties.properties
----------------------------------------------------------------------
diff --git a/camel-core/src/test/resources/org/apache/camel/component/properties/myproperties.properties
b/camel-core/src/test/resources/org/apache/camel/component/properties/myproperties.properties
index 64e6552..82c9e79 100644
--- a/camel-core/src/test/resources/org/apache/camel/component/properties/myproperties.properties
+++ b/camel-core/src/test/resources/org/apache/camel/component/properties/myproperties.properties
@@ -36,6 +36,8 @@ cool.mock=mock
 myCoolCharset=iso-8859-1
 slipDelimiter=##
 
+myDelayPattern=3:1000;5:3000;10:5000;20:10000
+
 stop=true
 
 


Mime
View raw message