Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x a65ea3371 -> 836eb87ee


Fixed CamelCatalog to construct endpoint uris for netty endpoints


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

Branch: refs/heads/camel-2.16.x
Commit: c9bfb4f776503f0e2ba28ebfe8bb0f82211cf7aa
Parents: a65ea33
Author: Claus Ibsen <davscl...@apache.org>
Authored: Sun Nov 1 17:15:11 2015 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Sun Nov 1 17:20:02 2015 +0100

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


http://git-wip-us.apache.org/repos/asf/camel/blob/c9bfb4f7/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 45c63fc..ed3837c 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
@@ -40,6 +40,7 @@ import javax.xml.xpath.XPathFactory;
 
 import org.w3c.dom.Document;
 
+import static org.apache.camel.catalog.CatalogHelper.after;
 import static 
org.apache.camel.catalog.JSonSchemaHelper.getPropertyDefaultValue;
 import static org.apache.camel.catalog.JSonSchemaHelper.isPropertyRequired;
 import static org.apache.camel.catalog.URISupport.createQueryString;
@@ -672,6 +673,9 @@ public class DefaultCamelCatalog implements CamelCatalog {
             throw new IllegalArgumentException("Endpoint with scheme " + 
scheme + " has no syntax defined in the json schema");
         }
 
+        // clip the scheme from the syntax
+        syntax = after(syntax, ":");
+
         String originalSyntax = syntax;
 
         // build at first according to syntax (use a tree map as we want the 
uri options sorted)
@@ -707,16 +711,23 @@ public class DefaultCamelCatalog implements CamelCatalog {
 
         // build the endpoint
         StringBuilder sb = new StringBuilder();
+        sb.append(scheme);
+        sb.append(":");
+
         int range = 0;
+        boolean first = true;
         for (int i = 0; i < options.size(); i++) {
             String key = options.get(i);
             String key2 = options2.get(i);
             String token = tokens[i];
 
             // was the option provided?
-            if (i == 0 || properties.containsKey(key)) {
-                sb.append(token);
+            if (properties.containsKey(key)) {
+                if (!first) {
+                    sb.append(token);
+                }
                 sb.append(key2);
+                first = false;
             }
             range++;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/c9bfb4f7/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 0d1e803..98962df 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
@@ -150,6 +150,19 @@ public class CamelCatalogTest extends TestCase {
     }
 
     @Test
+    public void testAsEndpointUriNetty4http() throws Exception {
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("protocol", "http");
+        map.put("host", "localhost");
+        map.put("port", "8080");
+        map.put("path", "foo/bar");
+        map.put("disconnect", "true");
+
+        String uri = catalog.asEndpointUri("netty4-http", map);
+        
assertEquals("netty4-http:http:localhost:8080/foo/bar?disconnect=true", uri);
+    }
+
+    @Test
     public void testAsEndpointUriMapJmsRequiredOnly() throws Exception {
         Map<String, String> map = new HashMap<String, String>();
         map.put("destinationName", "foo");

Reply via email to