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/da382fcd Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/da382fcd Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/da382fcd Branch: refs/heads/camel-2.16.x Commit: da382fcdda716f7e0c4e72f5c8a1282f5f024e1a Parents: adf4c8c Author: Claus Ibsen <[email protected]> Authored: Thu Jan 7 20:11:00 2016 +0100 Committer: Claus Ibsen <[email protected]> Committed: Thu Jan 7 20:17:28 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/da382fcd/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/da382fcd/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
