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 - Add special logic for validaing activemq/jms as its a bit special in its destinationType path param.
Date Sun, 17 Jan 2016 09:42:57 GMT
Camel catalog - Add special logic for validaing activemq/jms as its a bit special in its destinationType
path param.


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

Branch: refs/heads/camel-2.16.x
Commit: 0aba642a69aa9eed5d0a83fd417a5975c6cf1b8e
Parents: 54e8e61
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Jan 17 10:40:05 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Jan 17 10:42:40 2016 +0100

----------------------------------------------------------------------
 platforms/catalog/pom.xml                            |  8 ++++++++
 .../apache/camel/catalog/DefaultCamelCatalog.java    | 15 +++++++++++++--
 .../org/apache/camel/catalog/CamelCatalogTest.java   | 10 ++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0aba642a/platforms/catalog/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog/pom.xml b/platforms/catalog/pom.xml
index da167ac..e1d0cd8 100644
--- a/platforms/catalog/pom.xml
+++ b/platforms/catalog/pom.xml
@@ -48,6 +48,14 @@
       <scope>test</scope>
     </dependency>
 
+    <!-- for testing activemq component -->
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>activemq-camel</artifactId>
+      <version>${activemq-version}</version>
+      <scope>test</scope>
+    </dependency>
+
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>

http://git-wip-us.apache.org/repos/asf/camel/blob/0aba642a/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 c178184..4624a5e 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
@@ -1056,6 +1056,16 @@ public class DefaultCamelCatalog implements CamelCatalog {
         // find the position where each option start/end
         List<String> word2 = new ArrayList<String>();
         int prev = 0;
+        int prevPath = 0;
+
+        // special for activemq/jms where the enum for destinationType causes a token issue
as it includes a colon
+        // for 'temp:queue' and 'temp:topic' values
+        if ("activemq".equals(scheme) || "jms".equals("scheme")) {
+            if (uriPath.startsWith("temp:")) {
+                prevPath = 5;
+            }
+        }
+
         for (String token : tokens) {
             if (token.isEmpty()) {
                 continue;
@@ -1065,11 +1075,11 @@ public class DefaultCamelCatalog implements CamelCatalog {
             int idx = -1;
             int len = 0;
             if (":".equals(token)) {
-                idx = uriPath.indexOf("://", prev);
+                idx = uriPath.indexOf("://", prevPath);
                 len = 3;
             }
             if (idx == -1) {
-                idx = uriPath.indexOf(token, prev);
+                idx = uriPath.indexOf(token, prevPath);
                 len = token.length();
             }
 
@@ -1077,6 +1087,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
                 String option = uriPath.substring(prev, idx);
                 word2.add(option);
                 prev = idx + len;
+                prevPath = prev;
             }
         }
         // special for last or if we did not add anyone

http://git-wip-us.apache.org/repos/asf/camel/blob/0aba642a/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 8af0a29..57ad517 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
@@ -412,6 +412,16 @@ public class CamelCatalogTest {
     }
 
     @Test
+    public void validateActiveMQProperties() throws Exception {
+        // add activemq as known component
+        catalog.addComponent("activemq", "org.apache.activemq.camel.component.ActiveMQComponent");
+
+        // activemq
+        EndpointValidationResult result = catalog.validateEndpointProperties("activemq:temp:queue:cheese");
+        assertTrue(result.isSuccess());
+    }
+
+    @Test
     public void validateProperties() throws Exception {
         // valid
         EndpointValidationResult result = catalog.validateEndpointProperties("log:mylog");


Mime
View raw message