camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/4] camel git commit: Camel catalog - Fixed validator
Date Thu, 07 Jan 2016 19:17:41 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x adf4c8c08 -> cf474047d
  refs/heads/master fb6208f56 -> eef022e26


Camel catalog - Fixed validator


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

Branch: refs/heads/master
Commit: 2170df830ee21b8719a4d70ca620d204c11d6a5a
Parents: fb6208f
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Jan 7 20:11:00 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Jan 7 20:11:00 2016 +0100

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


http://git-wip-us.apache.org/repos/asf/camel/blob/2170df83/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 e106897..028a43b 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
@@ -794,7 +794,8 @@ public class DefaultCamelCatalog implements CamelCatalog {
 
             String prefix = getPropertyPrefix(rows, name);
             String kind = getPropertyKind(rows, name);
-            boolean placeholder = value.startsWith("{{") || value.startsWith("${") || value.startsWith("$simple{");
+            boolean namePlaceholder = name.startsWith("{{") && name.endsWith("}}");
+            boolean valuePlaceholder = value.startsWith("{{") || value.startsWith("${") ||
value.startsWith("$simple{");
             boolean lookup = value.startsWith("#") && value.length() > 1;
             // we cannot evaluate multi values as strict as the others, as we don't know
their expected types
             boolean mulitValue = prefix != null && originalName.startsWith(prefix)
&& isPropertyMultiValue(rows, name);
@@ -804,8 +805,9 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 // unknown option
 
                 // only add as error if the component is not lenient properties, or not stub
component
+                // and the name is not a property placeholder for one or more values
                 // as if we are lenient then the option is a dynamic extra option which we
cannot validate
-                if (!lenientProperties && !"stub".equals(scheme)) {
+                if (!namePlaceholder && !lenientProperties && !"stub".equals(scheme))
{
                     result.addUnknown(name);
                     if (suggestionStrategy != null) {
                         String[] suggestions = suggestionStrategy.suggestEndpointOptions(getNames(rows),
name);
@@ -830,7 +832,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 (!mulitValue && !placeholder && !lookup && enums
!= null) {
+                if (!mulitValue && !valuePlaceholder && !lookup &&
enums != null) {
                     String[] choices = enums.split(",");
                     boolean found = false;
                     for (String s : choices) {
@@ -854,7 +856,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 }
 
                 // is boolean
-                if (!mulitValue && !placeholder && !lookup && isPropertyBoolean(rows,
name)) {
+                if (!mulitValue && !valuePlaceholder && !lookup &&
isPropertyBoolean(rows, name)) {
                     // value must be a boolean
                     boolean bool = "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
                     if (!bool) {
@@ -863,7 +865,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 }
 
                 // is integer
-                if (!mulitValue && !placeholder && !lookup && isPropertyInteger(rows,
name)) {
+                if (!mulitValue && !valuePlaceholder && !lookup &&
isPropertyInteger(rows, name)) {
                     // value must be an integer
                     boolean valid = validateInteger(value);
                     if (!valid) {
@@ -872,7 +874,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 }
 
                 // is number
-                if (!mulitValue && !placeholder && !lookup && isPropertyNumber(rows,
name)) {
+                if (!mulitValue && !valuePlaceholder && !lookup &&
isPropertyNumber(rows, name)) {
                     // value must be an number
                     boolean valid = false;
                     try {

http://git-wip-us.apache.org/repos/asf/camel/blob/2170df83/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 26b4788..ded4da0 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
@@ -532,6 +532,10 @@ public class CamelCatalogTest {
         // userinfo in authority without password
         result = catalog.validateEndpointProperties("ssh://scott@localhost:8101?certResource=classpath:test_rsa&useFixedDelay=true&delay=5000&pollCommand=features:list%0A");
         assertTrue(result.isSuccess());
+
+        // placeholder for a bunch of optional options
+        result = catalog.validateEndpointProperties("aws-swf://activity?{{options}}");
+        assertTrue(result.isSuccess());
     }
 
     @Test


Mime
View raw message