camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: Camel catalog - Improve validation of dataformat endpoint as we can use the df scheme to validate its options.
Date Tue, 05 Jan 2016 12:34:00 GMT
Camel catalog - Improve validation of dataformat endpoint as we can use the df scheme to validate
its options.


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

Branch: refs/heads/camel-2.16.x
Commit: d739530dbf7da5eb2b5aa903593d3dce3f057b48
Parents: e9cdfba
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jan 5 13:32:59 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Jan 5 13:33:51 2016 +0100

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


http://git-wip-us.apache.org/repos/asf/camel/blob/d739530d/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 6c5c444..f04bd3f 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
@@ -766,6 +766,19 @@ public class DefaultCamelCatalog implements CamelCatalog {
             return result;
         }
 
+        // the dataformat component refers to a data format so lets add the properties for
the selected
+        // data format to the list of rows
+        if ("dataformat".equals(scheme)) {
+            String dfName = properties.get("name");
+            if (dfName != null) {
+                String dfJson = dataFormatJSonSchema(dfName);
+                List<Map<String, String>> dfRows = JSonSchemaHelper.parseJsonSchema("properties",
dfJson, true);
+                if (dfRows != null && !dfRows.isEmpty()) {
+                    rows.addAll(dfRows);
+                }
+            }
+        }
+
         // validate all the options
         for (Map.Entry<String, String> property : properties.entrySet()) {
             String value = property.getValue();

http://git-wip-us.apache.org/repos/asf/camel/blob/d739530d/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 d20cfa0..b59f872 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
@@ -497,6 +497,10 @@ public class CamelCatalogTest {
         result = catalog.validateEndpointProperties("dataformat:string:marshal?foo=bar",
true);
         assertFalse(result.isSuccess());
         assertTrue(result.getUnknown().contains("foo"));
+
+        // data format
+        result = catalog.validateEndpointProperties("dataformat:string:marshal?charset=utf-8",
true);
+        assertTrue(result.isSuccess());
     }
 
     @Test


Mime
View raw message