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/05/22 03:34:58 UTC
[camel] branch master updated (7031b0e -> 6128c69)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from 7031b0e Regen (again)
new f0fd289 CAMEL-13534 Adding colon as alternative syntax style
new 6128c69 CAMEL-13534 Adding documentation
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../simple/ast/SimpleFunctionExpression.java | 16 +++++++--
.../apache/camel/language/simple/SimpleTest.java | 40 ++++++++++++++++++----
.../modules/ROOT/pages/simple-language.adoc | 12 +++++++
3 files changed, 59 insertions(+), 9 deletions(-)
[camel] 01/02: CAMEL-13534 Adding colon as alternative syntax style
Posted by da...@apache.org.
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
commit f0fd289744cc9bced1081257c20f4608882442dc
Author: Dimitrios Liapis <di...@gmail.com>
AuthorDate: Tue May 21 17:23:04 2019 +0200
CAMEL-13534 Adding colon as alternative syntax style
---
.../simple/ast/SimpleFunctionExpression.java | 16 +++++++--
.../apache/camel/language/simple/SimpleTest.java | 40 ++++++++++++++++++----
2 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/core/camel-base/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java b/core/camel-base/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
index c3e2a01..641a8ca 100644
--- a/core/camel-base/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
+++ b/core/camel-base/src/main/java/org/apache/camel/language/simple/ast/SimpleFunctionExpression.java
@@ -150,8 +150,14 @@ public class SimpleFunctionExpression extends LiteralExpression {
}
remainder = ifStartsWithReturnRemainder("sysenv.", function);
if (remainder == null) {
+ remainder = ifStartsWithReturnRemainder("sysenv:", function);
+ }
+ if (remainder == null) {
remainder = ifStartsWithReturnRemainder("env.", function);
}
+ if (remainder == null) {
+ remainder = ifStartsWithReturnRemainder("env:", function);
+ }
if (remainder != null) {
return ExpressionBuilder.systemEnvironmentExpression(remainder);
}
@@ -355,8 +361,8 @@ public class SimpleFunctionExpression extends LiteralExpression {
remainder = ifStartsWithReturnRemainder("header", function);
}
if (remainder != null) {
- // remove leading character (dot or ?)
- if (remainder.startsWith(".") || remainder.startsWith("?")) {
+ // remove leading character (dot, colon or ?)
+ if (remainder.startsWith(".") || remainder.startsWith(":") || remainder.startsWith("?")) {
remainder = remainder.substring(1);
}
// remove starting and ending brackets
@@ -384,8 +390,14 @@ public class SimpleFunctionExpression extends LiteralExpression {
// out header function
remainder = ifStartsWithReturnRemainder("out.header.", function);
if (remainder == null) {
+ remainder = ifStartsWithReturnRemainder("out.header:", function);
+ }
+ if (remainder == null) {
remainder = ifStartsWithReturnRemainder("out.headers.", function);
}
+ if (remainder == null) {
+ remainder = ifStartsWithReturnRemainder("out.headers:", function);
+ }
if (remainder != null) {
return ExpressionBuilder.outHeaderExpression(remainder);
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
index 39d09e1..261d18b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java
@@ -164,7 +164,7 @@ public class SimpleTest extends LanguageTestSupport {
public void testBodyOgnlExpression() throws Exception {
Expression exp = SimpleLanguage.simple("${body.xxx}");
assertNotNull(exp);
-
+
// must start with a dot
try {
SimpleLanguage.simple("${bodyxxx}");
@@ -248,7 +248,9 @@ public class SimpleTest extends LanguageTestSupport {
exchange.getOut().setHeader("quote", "Camel rocks");
assertExpression("${out.body}", "Bye World");
assertExpression("${out.header.quote}", "Camel rocks");
+ assertExpression("${out.header:quote}", "Camel rocks");
assertExpression("${out.headers.quote}", "Camel rocks");
+ assertExpression("${out.headers:quote}", "Camel rocks");
}
@Test
@@ -268,16 +270,20 @@ public class SimpleTest extends LanguageTestSupport {
String path = System.getenv("PATH");
if (path != null) {
assertExpression("${sysenv.PATH}", path);
+ assertExpression("${sysenv:PATH}", path);
assertExpression("${env.PATH}", path);
+ assertExpression("${env:PATH}", path);
}
}
-
+
@Test
public void testSimpleSystemEnvironmentExpressionsIfDash() throws Exception {
String foo = System.getenv("FOO_SERVICE_HOST");
if (foo != null) {
assertExpression("${sysenv.FOO-SERVICE-HOST}", foo);
+ assertExpression("${sysenv:FOO-SERVICE-HOST}", foo);
assertExpression("${env.FOO-SERVICE-HOST}", foo);
+ assertExpression("${env:FOO-SERVICE-HOST}", foo);
}
}
@@ -286,7 +292,9 @@ public class SimpleTest extends LanguageTestSupport {
String path = System.getenv("PATH");
if (path != null) {
assertExpression("${sysenv.path}", path);
+ assertExpression("${sysenv:path}", path);
assertExpression("${env.path}", path);
+ assertExpression("${env:path}", path);
}
}
@@ -418,11 +426,11 @@ public class SimpleTest extends LanguageTestSupport {
} catch (Exception e) {
IndexOutOfBoundsException cause = assertIsInstanceOf(IndexOutOfBoundsException.class, e.getCause());
if (getJavaMajorVersion() <= 8) {
- assertEquals(JAVA8_INDEX_OUT_OF_BOUNDS_ERROR_MSG, cause.getMessage());
+ assertEquals(JAVA8_INDEX_OUT_OF_BOUNDS_ERROR_MSG, cause.getMessage());
} else {
assertEquals(INDEX_OUT_OF_BOUNDS_ERROR_MSG, cause.getMessage());
}
-
+
}
assertExpression("${exchangeProperty.unknown[cool]}", null);
}
@@ -551,7 +559,7 @@ public class SimpleTest extends LanguageTestSupport {
Calendar inHeaderCalendar = Calendar.getInstance();
inHeaderCalendar.set(1974, Calendar.APRIL, 20);
exchange.getIn().setHeader("birthday", inHeaderCalendar.getTime());
-
+
Calendar outHeaderCalendar = Calendar.getInstance();
outHeaderCalendar.set(1975, Calendar.MAY, 21);
exchange.getOut().setHeader("birthday", outHeaderCalendar.getTime());
@@ -563,11 +571,11 @@ public class SimpleTest extends LanguageTestSupport {
assertExpression("${date:header.birthday}", inHeaderCalendar.getTime());
assertExpression("${date:header.birthday:yyyyMMdd}", "19740420");
assertExpression("${date:header.birthday+24h:yyyyMMdd}", "19740421");
-
+
assertExpression("${date:in.header.birthday}", inHeaderCalendar.getTime());
assertExpression("${date:in.header.birthday:yyyyMMdd}", "19740420");
assertExpression("${date:in.header.birthday+24h:yyyyMMdd}", "19740421");
-
+
assertExpression("${date:out.header.birthday}", outHeaderCalendar.getTime());
assertExpression("${date:out.header.birthday:yyyyMMdd}", "19750521");
assertExpression("${date:out.header.birthday+24h:yyyyMMdd}", "19750522");
@@ -631,23 +639,37 @@ public class SimpleTest extends LanguageTestSupport {
@Test
public void testComplexExpressions() throws Exception {
assertExpression("hey ${in.header.foo}", "hey abc");
+ assertExpression("hey ${in.header:foo}", "hey abc");
assertExpression("hey ${in.header.foo}!", "hey abc!");
+ assertExpression("hey ${in.header:foo}!", "hey abc!");
assertExpression("hey ${in.header.foo}-${in.header.foo}!", "hey abc-abc!");
+ assertExpression("hey ${in.header:foo}-${in.header.foo}!", "hey abc-abc!");
assertExpression("hey ${in.header.foo}${in.header.foo}", "hey abcabc");
+ assertExpression("hey ${in.header:foo}${in.header.foo}", "hey abcabc");
assertExpression("${in.header.foo}${in.header.foo}", "abcabc");
+ assertExpression("${in.header:foo}${in.header:foo}", "abcabc");
assertExpression("${in.header.foo}", "abc");
+ assertExpression("${in.header:foo}", "abc");
assertExpression("${in.header.foo}!", "abc!");
+ assertExpression("${in.header:foo}!", "abc!");
}
@Test
public void testComplexExpressionsUsingAlternativeStartToken() throws Exception {
assertExpression("hey $simple{in.header.foo}", "hey abc");
+ assertExpression("hey $simple{in.header:foo}", "hey abc");
assertExpression("hey $simple{in.header.foo}!", "hey abc!");
+ assertExpression("hey $simple{in.header:foo}!", "hey abc!");
assertExpression("hey $simple{in.header.foo}-$simple{in.header.foo}!", "hey abc-abc!");
+ assertExpression("hey $simple{in.header:foo}-$simple{in.header.foo}!", "hey abc-abc!");
assertExpression("hey $simple{in.header.foo}$simple{in.header.foo}", "hey abcabc");
+ assertExpression("hey $simple{in.header:foo}$simple{in.header.foo}", "hey abcabc");
assertExpression("$simple{in.header.foo}$simple{in.header.foo}", "abcabc");
+ assertExpression("$simple{in.header:foo}$simple{in.header.foo}", "abcabc");
assertExpression("$simple{in.header.foo}", "abc");
+ assertExpression("$simple{in.header:foo}", "abc");
assertExpression("$simple{in.header.foo}!", "abc!");
+ assertExpression("$simple{in.header:foo}!", "abc!");
}
@Test
@@ -747,9 +769,13 @@ public class SimpleTest extends LanguageTestSupport {
exchange.getIn().setBody(null);
assertExpression("${header.foo}", "abc");
+ assertExpression("${header:foo}", "abc");
assertExpression("${headers.foo}", "abc");
+ assertExpression("${headers:foo}", "abc");
assertExpression("${in.header.foo}", "abc");
+ assertExpression("${in.header:foo}", "abc");
assertExpression("${in.headers.foo}", "abc");
+ assertExpression("${in.headers:foo}", "abc");
}
@Test
[camel] 02/02: CAMEL-13534 Adding documentation
Posted by da...@apache.org.
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
commit 6128c697bf57b89fb567df642eb498722056b06c
Author: Dimitrios Liapis <di...@gmail.com>
AuthorDate: Tue May 21 17:26:48 2019 +0200
CAMEL-13534 Adding documentation
---
docs/user-manual/modules/ROOT/pages/simple-language.adoc | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/docs/user-manual/modules/ROOT/pages/simple-language.adoc b/docs/user-manual/modules/ROOT/pages/simple-language.adoc
index aa063ff..fa1aff4 100644
--- a/docs/user-manual/modules/ROOT/pages/simple-language.adoc
+++ b/docs/user-manual/modules/ROOT/pages/simple-language.adoc
@@ -88,18 +88,26 @@ classname and then invoke methods using a Camel OGNL expression.
|header.foo |Object |refer to the input foo header
+|header:foo |Object |refer to the input foo header
+
|header[foo] |Object |refer to the input foo header
|headers.foo |Object |refer to the input foo header
+|headers:foo |Object |refer to the input foo header
+
|headers[foo] |Object |refer to the input foo header
|in.header.foo |Object |*deprecated* refer to the input foo header
+|in.header:foo |Object |*deprecated* refer to the input foo header
+
|in.header[foo] |Object |*deprecated* refer to the input foo header
|in.headers.foo |Object |*deprecated* refer to the input foo header
+|in.headers:foo |Object |*deprecated* refer to the input foo header
+
|in.headers[foo] |Object |*deprecated* refer to the input foo header
|header.foo[bar] |Object |regard input foo header as a map and perform lookup on the
@@ -122,10 +130,14 @@ Camel OGNL expression.
|out.header.foo |Object |*deprecated* refer to the out header foo
+|out.header:foo |Object |*deprecated* refer to the out header foo
+
|out.header[foo] |Object |*deprecated* refer to the out header foo
|out.headers.foo |Object |*deprecated* refer to the out header foo
+|out.headers:foo |Object |*deprecated* refer to the out header foo
+
|out.headers[foo] |Object |*deprecated* refer to the out header foo
|headerAs(_key_,_type_) |Type |converts the header to the given type determined by its