camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hekon...@apache.org
Subject camel git commit: [CAMEL-9245] camel-paho - Endpoint should allow a flexible naming.
Date Sun, 25 Oct 2015 20:28:47 GMT
Repository: camel
Updated Branches:
  refs/heads/master 0ddf4b1ca -> 14e9236ac


[CAMEL-9245] camel-paho - Endpoint should allow a flexible naming.


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

Branch: refs/heads/master
Commit: 14e9236aca9e1cd93f180158767d7e102257f1b6
Parents: 0ddf4b1
Author: Henryk Konsek <hekonsek@gmail.com>
Authored: Sun Oct 25 21:28:39 2015 +0100
Committer: Henryk Konsek <hekonsek@gmail.com>
Committed: Sun Oct 25 21:28:39 2015 +0100

----------------------------------------------------------------------
 .../camel/component/paho/PahoComponent.java     |  2 +-
 .../camel/component/paho/PahoEndpoint.java      | 11 ++-------
 .../camel/component/paho/PahoComponentTest.java | 24 +++++++++++++++++++-
 3 files changed, 26 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/14e9236a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoComponent.java
b/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoComponent.java
index c9cbc41..3756a67 100644
--- a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoComponent.java
+++ b/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoComponent.java
@@ -34,7 +34,7 @@ public class PahoComponent extends UriEndpointComponent {
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
-        PahoEndpoint answer = new PahoEndpoint(uri, this);
+        PahoEndpoint answer = new PahoEndpoint(uri, remaining, this);
 
         if (brokerUrl != null) {
             answer.setBrokerUrl(brokerUrl);

http://git-wip-us.apache.org/repos/asf/camel/blob/14e9236a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
b/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
index 4264522..bc6ee97 100644
--- a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
+++ b/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
@@ -71,16 +71,9 @@ public class PahoEndpoint extends DefaultEndpoint {
 
     private transient MqttClient client;
 
-    public PahoEndpoint(String uri, Component component) {
+    public PahoEndpoint(String uri, String topic, Component component) {
         super(uri, component);
-        if (topic == null) {
-            int optionIndex = uri.indexOf("?");
-            if (optionIndex > 0) {
-                topic = uri.substring(7, optionIndex);
-            } else {
-                topic = uri.substring(7);
-            }
-        }
+        this.topic = topic;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/14e9236a/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
b/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
index 8013f8f..27f0ed8 100644
--- a/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
+++ b/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
@@ -36,7 +36,10 @@ public class PahoComponentTest extends CamelTestSupport {
 
     @EndpointInject(uri = "mock:test")
     MockEndpoint mock;
-    
+
+    @EndpointInject(uri = "mock:testCustomizedPaho")
+    MockEndpoint testCustomizedPahoMock;
+
     BrokerService broker;
 
     int mqttPort = AvailablePortFinder.getNextAvailable();
@@ -66,6 +69,9 @@ public class PahoComponentTest extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                PahoComponent customizedPaho = new PahoComponent();
+                context.addComponent("customizedPaho", customizedPaho);
+
                 from("direct:test").to("paho:queue?brokerUrl=tcp://localhost:" + mqttPort);
                 from("paho:queue?brokerUrl=tcp://localhost:" + mqttPort).to("mock:test");
 
@@ -74,6 +80,9 @@ public class PahoComponentTest extends CamelTestSupport {
                 from("paho:persistenceTest?persistence=FILE&brokerUrl=tcp://localhost:"
+ mqttPort).to("mock:persistenceTest");
 
                 from("direct:connectOptions").to("paho:registryConnectOptions?connectOptions=#connectOptions&brokerUrl=tcp://localhost:"
+ mqttPort);
+
+                from("direct:testCustomizedPaho").to("customizedPaho:testCustomizedPaho?brokerUrl=tcp://localhost:"
+ mqttPort);
+                from("paho:testCustomizedPaho?brokerUrl=tcp://localhost:" + mqttPort).to("mock:testCustomizedPaho");
             }
         };
     }
@@ -189,4 +198,17 @@ public class PahoComponentTest extends CamelTestSupport {
         assertEquals(msg, new String(message.getPayload()));
     }
 
+    @Test
+    public void shouldReadMessageFromCustomizedComponent() throws InterruptedException {
+        // Given
+        String msg = "msg";
+        testCustomizedPahoMock.expectedBodiesReceived(msg);
+
+        // When
+        template.sendBody("direct:testCustomizedPaho", msg);
+
+        // Then
+        testCustomizedPahoMock.assertIsSatisfied();
+    }
+
 }


Mime
View raw message