camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: Camel catalog - Validate uris with lookup value should be valid for any kind of type.
Date Sun, 03 Jan 2016 11:49:50 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x 6c211d494 -> 9248691dc
  refs/heads/master ff75709b4 -> e49eb8f4e


Camel catalog - Validate uris with lookup value should be valid for any kind of type.


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

Branch: refs/heads/master
Commit: e49eb8f4ee3189f8342f79a4f76e5378e897726d
Parents: ff75709
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Jan 3 12:49:20 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Jan 3 12:49:20 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/catalog/DefaultCamelCatalog.java  | 9 +++++----
 .../java/org/apache/camel/catalog/CamelCatalogTest.java     | 4 ++++
 2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e49eb8f4/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index c4322f0..b8dcc92 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -754,6 +754,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
             String name = property.getKey();
             String value = property.getValue();
             boolean placeholder = value.startsWith("{{") || value.startsWith("${") || value.startsWith("$simple{");
+            boolean lookup = value.startsWith("#") && value.length() > 1;
 
             Map<String, String> row = getRow(rows, name);
             if (row == null) {
@@ -781,7 +782,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 // is enum but the value is not within the enum range
                 // but we can only check if the value is not a placeholder
                 String enums = getPropertyEnum(rows, name);
-                if (!placeholder && enums != null) {
+                if (!placeholder && !lookup && enums != null) {
                     String[] choices = enums.split(",");
                     boolean found = false;
                     for (String s : choices) {
@@ -806,7 +807,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 }
 
                 // is boolean
-                if (!placeholder && isPropertyBoolean(rows, name)) {
+                if (!placeholder && !lookup && isPropertyBoolean(rows, name))
{
                     // value must be a boolean
                     boolean bool = "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
                     if (!bool) {
@@ -815,7 +816,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 }
 
                 // is integer
-                if (!placeholder && isPropertyInteger(rows, name)) {
+                if (!placeholder && !lookup && isPropertyInteger(rows, name))
{
                     // value must be an integer
                     boolean valid = validateInteger(value);
                     if (!valid) {
@@ -824,7 +825,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 }
 
                 // is number
-                if (!placeholder && isPropertyNumber(rows, name)) {
+                if (!placeholder && !lookup && isPropertyNumber(rows, name))
{
                     // value must be an number
                     boolean valid = false;
                     try {

http://git-wip-us.apache.org/repos/asf/camel/blob/e49eb8f4/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
index 4387374..cefa765 100644
--- a/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
+++ b/platforms/catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java
@@ -464,6 +464,10 @@ public class CamelCatalogTest {
         // time pattern
         result = catalog.validateEndpointProperties("timer://foo?fixedRate=true&delay=0&period=2s");
         assertTrue(result.isSuccess());
+
+        // reference lookup
+        result = catalog.validateEndpointProperties("timer://foo?fixedRate=#fixed&delay=#myDelay");
+        assertTrue(result.isSuccess());
     }
 
     @Test


Mime
View raw message