Camel component docs - Should include information if an endpoint is lenient properties
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e9cdfbaf Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e9cdfbaf Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e9cdfbaf Branch: refs/heads/camel-2.16.x Commit: e9cdfbafee708cee3df63e69bdf7f94865d3ca9c Parents: 3d69dc7 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Jan 5 12:46:55 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Jan 5 12:47:22 2016 +0100 ---------------------------------------------------------------------- .../java/org/apache/camel/catalog/CamelCatalog.java | 16 +++++++++++++++- .../apache/camel/catalog/DefaultCamelCatalog.java | 8 +++++++- .../org/apache/camel/catalog/CamelCatalogTest.java | 7 ++++++- 3 files changed, 28 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e9cdfbaf/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java ---------------------------------------------------------------------- diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java index 4d3f5e4..f1c2bb6 100644 --- a/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java +++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java @@ -191,7 +191,7 @@ public interface CamelCatalog { Map<String, String> endpointProperties(String uri) throws URISyntaxException; /** - * Parses and validates the endpoint uri and constructs a key/value properties of each option + * Parses and validates the endpoint uri and constructs a key/value properties of each option. * * @param uri the endpoint uri * @return validation result @@ -199,6 +199,20 @@ public interface CamelCatalog { EndpointValidationResult validateEndpointProperties(String uri); /** + * Parses and validates the endpoint uri and constructs a key/value properties of each option. + * <p/> + * The option ignoreLenientProperties can be used to ignore components that uses lenient properties. + * When this is true, then the uri validation is stricter but would fail on properties that are not part of the component + * but in the uri because of using lenient properties. + * For example using the HTTP components to provide query parameters in the endpoint uri. + * + * @param uri the endpoint uri + * @param ignoreLenientProperties whether to ignore components that uses lenient properties. + * @return validation result + */ + EndpointValidationResult validateEndpointProperties(String uri, boolean ignoreLenientProperties); + + /** * Parses and validates the simple expression. * <p/> * <b>Important:</b> This requires having <tt>camel-core</tt> on the classpath http://git-wip-us.apache.org/repos/asf/camel/blob/e9cdfbaf/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 5a023c9..6c5c444 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 @@ -733,6 +733,11 @@ public class DefaultCamelCatalog implements CamelCatalog { @Override public EndpointValidationResult validateEndpointProperties(String uri) { + return validateEndpointProperties(uri, false); + } + + @Override + public EndpointValidationResult validateEndpointProperties(String uri, boolean ignoreLenientProperties) { EndpointValidationResult result = new EndpointValidationResult(uri); Map<String, String> properties; @@ -751,7 +756,8 @@ public class DefaultCamelCatalog implements CamelCatalog { } rows = JSonSchemaHelper.parseJsonSchema("component", json, false); - lenientProperties = isComponentLenientProperties(rows); + // only enable lenient properties if we should not ignore + lenientProperties = !ignoreLenientProperties && isComponentLenientProperties(rows); rows = JSonSchemaHelper.parseJsonSchema("properties", json, true); properties = endpointProperties(uri); http://git-wip-us.apache.org/repos/asf/camel/blob/e9cdfbaf/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 f32597a..d20cfa0 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 @@ -489,9 +489,14 @@ public class CamelCatalogTest { result = catalog.validateEndpointProperties("stub:foo?me=123&you=456"); assertTrue(result.isSuccess()); - // lenient + // lenient on result = catalog.validateEndpointProperties("dataformat:string:marshal?foo=bar"); assertTrue(result.isSuccess()); + + // lenient off + result = catalog.validateEndpointProperties("dataformat:string:marshal?foo=bar", true); + assertFalse(result.isSuccess()); + assertTrue(result.getUnknown().contains("foo")); } @Test