Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 89BA8182BC for ; Sat, 2 Jan 2016 22:27:15 +0000 (UTC) Received: (qmail 41064 invoked by uid 500); 2 Jan 2016 22:27:15 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 40996 invoked by uid 500); 2 Jan 2016 22:27:15 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 40978 invoked by uid 99); 2 Jan 2016 22:27:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jan 2016 22:27:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1E430E048C; Sat, 2 Jan 2016 22:27:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Sat, 02 Jan 2016 22:27:15 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] camel git commit: Camel catalog - Add api to validate Repository: camel Updated Branches: refs/heads/camel-2.16.x 5e1300002 -> 920a0d5f9 refs/heads/master 7c52e786d -> b10c741fe Camel catalog - Add api to validate Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b10c741f Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b10c741f Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b10c741f Branch: refs/heads/master Commit: b10c741fe79b2ffc13710a7b109c3c3b520b1a29 Parents: 7c52e78 Author: Claus Ibsen Authored: Sat Jan 2 23:26:46 2016 +0100 Committer: Claus Ibsen Committed: Sat Jan 2 23:26:46 2016 +0100 ---------------------------------------------------------------------- .../apache/camel/catalog/DefaultCamelCatalog.java | 6 ++++-- .../org/apache/camel/catalog/JSonSchemaHelper.java | 17 +++++++++++++++++ .../org/apache/camel/catalog/CamelCatalogTest.java | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b10c741f/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 607a7e5..fc63bd0 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 @@ -46,6 +46,7 @@ import static org.apache.camel.catalog.CatalogHelper.after; import static org.apache.camel.catalog.JSonSchemaHelper.getNames; import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyDefaultValue; import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyEnum; +import static org.apache.camel.catalog.JSonSchemaHelper.getPropertyKind; import static org.apache.camel.catalog.JSonSchemaHelper.getRow; import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyBoolean; import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyInteger; @@ -795,8 +796,9 @@ public class DefaultCamelCatalog implements CamelCatalog { } } - // is reference lookup of bean - if (isPropertyObject(rows, name)) { + // is reference lookup of bean (not applicable for @UriPath) + String kind = getPropertyKind(rows, name); + if (!"path".equals(kind) && isPropertyObject(rows, name)) { // must start with # and be at least 2 characters if (!value.startsWith("#") || value.length() <= 1) { result.addInvalidReference(name, value); http://git-wip-us.apache.org/repos/asf/camel/blob/b10c741f/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java ---------------------------------------------------------------------- diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java index d262b6c..a4b27df 100644 --- a/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java +++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/JSonSchemaHelper.java @@ -131,6 +131,23 @@ public final class JSonSchemaHelper { return false; } + public static String getPropertyKind(List> rows, String name) { + for (Map row : rows) { + String kind = null; + boolean found = false; + if (row.containsKey("name")) { + found = name.equals(row.get("name")); + } + if (row.containsKey("kind")) { + kind = row.get("kind"); + } + if (found) { + return kind; + } + } + return null; + } + public static boolean isPropertyBoolean(List> rows, String name) { for (Map row : rows) { String type = null; http://git-wip-us.apache.org/repos/asf/camel/blob/b10c741f/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 259272b..b58ec15 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 @@ -456,6 +456,10 @@ public class CamelCatalogTest { assertFalse(result.isSuccess()); assertEquals("ggg", result.getInvalidBoolean().get("showAll")); assertEquals(1, result.getNumberOfErrors()); + + // dataset + result = catalog.validateEndpointProperties("dataset:foo?minRate=50"); + assertTrue(result.isSuccess()); } @Test