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-8509: camel-catalog - Add api to parse endpoint uri and reverse
Date Fri, 20 Mar 2015 12:12:18 GMT
CAMEL-8509: camel-catalog - Add api to parse endpoint uri and reverse


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

Branch: refs/heads/camel-2.15.x
Commit: 67c4937c37f6a9a237cbdbb610e05beaeaf52e03
Parents: 071be58
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Mar 20 13:13:41 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Mar 20 13:14:02 2015 +0100

----------------------------------------------------------------------
 .../camel/catalog/DefaultCamelCatalog.java      | 22 +++++++++++++++-----
 .../apache/camel/catalog/CamelCatalogTest.java  | 17 +++++++++++++++
 2 files changed, 34 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/67c4937c/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 e35fc37..bc10145 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
@@ -481,12 +481,24 @@ public class DefaultCamelCatalog implements CamelCatalog {
 
         String uriPath = stripQuery(uri);
 
-        Matcher matcher2 = SYNTAX_PATTERN.matcher(uriPath);
+        // if there is only one, then use uriPath as is
         List<String> word2 = new ArrayList<String>();
-        while (matcher2.find() ) {
-            String s = matcher2.group(1);
-            if (!scheme.equals(s)) {
-                word2.add(s);
+
+        if (word.size() == 1) {
+            String s = uriPath;
+            s = URISupport.stripPrefix(s, scheme);
+            // strip any leading : or / after the scheme
+            while (s.startsWith(":") || s.startsWith("/")) {
+                s = s.substring(1);
+            }
+            word2.add(s);
+        } else {
+            Matcher matcher2 = SYNTAX_PATTERN.matcher(uriPath);
+            while (matcher2.find()) {
+                String s = matcher2.group(1);
+                if (!scheme.equals(s)) {
+                    word2.add(s);
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/67c4937c/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 ad5c34c..6f9f510 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
@@ -172,4 +172,21 @@ public class CamelCatalogTest extends TestCase {
         assertEquals("false", map.get("deliveryPersistent"));
     }
 
+    @Test
+    public void testEndpointPropertiesAtom() throws Exception {
+        Map<String, String> map = catalog.endpointProperties("atom:file:src/test/data/feed.atom");
+        assertNotNull(map);
+        assertEquals(1, map.size());
+
+        assertEquals("file:src/test/data/feed.atom", map.get("feedUri"));
+
+        map = catalog.endpointProperties("atom:file:src/test/data/feed.atom?splitEntries=false&delay=5000");
+        assertNotNull(map);
+        assertEquals(3, map.size());
+
+        assertEquals("file:src/test/data/feed.atom", map.get("feedUri"));
+        assertEquals("false", map.get("splitEntries"));
+        assertEquals("5000", map.get("delay"));
+    }
+
 }


Mime
View raw message