You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/02/01 09:07:28 UTC

[camel] branch master updated: CAMEL-13150: Add command "exchangeProperty" for dateExpression in ExpressionBuilder (#2741)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 7a01924  CAMEL-13150: Add command "exchangeProperty" for dateExpression in ExpressionBuilder (#2741)
7a01924 is described below

commit 7a01924803ccc2648af900f2764e36e95ccc156a
Author: Anthony Defraine <ro...@kinae.eu>
AuthorDate: Fri Feb 1 09:59:20 2019 +0100

    CAMEL-13150: Add command "exchangeProperty" for dateExpression in ExpressionBuilder (#2741)
---
 .../src/main/java/org/apache/camel/builder/ExpressionBuilder.java     | 2 +-
 .../src/test/java/org/apache/camel/language/simple/SimpleTest.java    | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
index e93f087..7ac882d 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
@@ -1909,7 +1909,7 @@ public final class ExpressionBuilder {
                     if (date == null) {
                         throw new IllegalArgumentException("Cannot find java.util.Date object at command: " + command);
                     }
-                } else if (command.startsWith("property.")) {
+                } else if (command.startsWith("property.") || command.startsWith("exchangeProperty.")) {
                     String key = command.substring(command.lastIndexOf('.') + 1);
                     date = exchange.getProperty(key, Date.class);
                     if (date == null) {
diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index a127365..bc87c4a 100644
--- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -564,6 +564,10 @@ public class SimpleTest extends LanguageTestSupport {
         assertExpression("${date:property.birthday:yyyyMMdd}", "19760622");
         assertExpression("${date:property.birthday+24h:yyyyMMdd}", "19760623");
 
+        assertExpression("date:exchangeProperty.birthday", propertyCalendar.getTime());
+        assertExpression("date:exchangeProperty.birthday:yyyyMMdd", "19760622");
+        assertExpression("date:exchangeProperty.birthday+24h:yyyyMMdd", "19760623");
+
         try {
             assertExpression("${date:yyyyMMdd}", "19740420");
             fail("Should thrown an exception");