You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/11/16 18:24:39 UTC
camel git commit: Fixed catalog with uri path required and to use
default value if not provided as option.
Repository: camel
Updated Branches:
refs/heads/master 2d0c14284 -> 1d6966cdf
Fixed catalog with uri path required and to use default value if not provided as option.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1d6966cd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1d6966cd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1d6966cd
Branch: refs/heads/master
Commit: 1d6966cdf261587bc1013df1408bb9c1b2ea2523
Parents: 2d0c142
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 16 18:27:40 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 16 18:27:40 2015 +0100
----------------------------------------------------------------------
.../org/apache/camel/catalog/DefaultCamelCatalog.java | 14 ++++++++++++++
.../org/apache/camel/catalog/CamelCatalogTest.java | 10 ++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1d6966cd/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 047167b..3d99109 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
@@ -681,6 +681,8 @@ public class DefaultCamelCatalog implements CamelCatalog {
throw new IllegalArgumentException("Endpoint with scheme " + scheme + " has no syntax defined in the json schema");
}
+ rows = JSonSchemaHelper.parseJsonSchema("properties", json, true);
+
// clip the scheme from the syntax
syntax = after(syntax, ":");
@@ -733,6 +735,18 @@ public class DefaultCamelCatalog implements CamelCatalog {
token = tokens[i];
}
+ boolean contains = properties.containsKey(key);
+ if (!contains) {
+ // if the key are similar we have no explicit value and can try to find a default value if the option is required
+ if (isPropertyRequired(rows, key)) {
+ String value = getPropertyDefaultValue(rows, key);
+ if (value != null) {
+ properties.put(key, value);
+ key2 = value;
+ }
+ }
+ }
+
// was the option provided?
if (properties.containsKey(key)) {
if (!first && token != null) {
http://git-wip-us.apache.org/repos/asf/camel/blob/1d6966cd/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 e467ecc..86b1f78 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
@@ -153,7 +153,7 @@ public class CamelCatalogTest {
@Test
public void testAsEndpointUriNetty4http() throws Exception {
Map<String, String> map = new HashMap<String, String>();
- map.put("protocol", "http");
+ // use default protocol
map.put("host", "localhost");
map.put("port", "8080");
map.put("path", "foo/bar");
@@ -162,12 +162,18 @@ public class CamelCatalogTest {
String uri = catalog.asEndpointUri("netty4-http", map, true);
assertEquals("netty4-http:http:localhost:8080/foo/bar?disconnect=true", uri);
+ // lets add a protocol
+ map.put("protocol", "https");
+
+ uri = catalog.asEndpointUri("netty4-http", map, true);
+ assertEquals("netty4-http:https:localhost:8080/foo/bar?disconnect=true", uri);
+
// lets set a query parameter in the path
map.put("path", "foo/bar?verbose=true");
map.put("disconnect", "true");
uri = catalog.asEndpointUri("netty4-http", map, true);
- assertEquals("netty4-http:http:localhost:8080/foo/bar?verbose=true&disconnect=true", uri);
+ assertEquals("netty4-http:https:localhost:8080/foo/bar?verbose=true&disconnect=true", uri);
}
@Test