camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject camel git commit: components/camel-mqtt
Date Wed, 04 Mar 2015 12:39:07 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x 6ad7efdea -> 0568b1202


components/camel-mqtt


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

Branch: refs/heads/camel-2.14.x
Commit: 0568b1202953c41e671d16a284de7127f8879e2c
Parents: 6ad7efd
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Wed Mar 4 20:38:12 2015 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Wed Mar 4 20:38:12 2015 +0800

----------------------------------------------------------------------
 .../org/apache/camel/component/mqtt/MQTTComponent.java   |  5 +++++
 .../org/apache/camel/component/mqtt/MQTTBaseTest.java    |  1 +
 .../camel/component/mqtt/MQTTConfigurationTest.java      | 11 +++++++++++
 3 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0568b120/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
index 3e3444a..093d6f7 100644
--- a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
+++ b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
@@ -35,4 +35,9 @@ public class MQTTComponent extends DefaultComponent {
         MQTTEndpoint endpoint = new MQTTEndpoint(uri, this, configuration);
         return endpoint;
     }
+
+    @Override
+    public boolean useRawUri() {
+        return true; // to prevent MQTT "+" wildcard from being lost
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/0568b120/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTBaseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTBaseTest.java
b/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTBaseTest.java
index f29a392..882587a 100644
--- a/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTBaseTest.java
+++ b/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTBaseTest.java
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
 public abstract class MQTTBaseTest extends CamelTestSupport {
     protected static final Logger LOG = LoggerFactory.getLogger(MQTTBaseTest.class);
     protected static final String TEST_TOPIC = "ComponentTestTopic";
+    protected static final String TEST_WILDCARD_TOPIC = "base/+/#";
     protected BrokerService brokerService;
     protected int numberOfMessages = 100;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0568b120/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTConfigurationTest.java
b/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTConfigurationTest.java
index 6cc0f69..21d9c8f 100644
--- a/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTConfigurationTest.java
+++ b/components/camel-mqtt/src/test/java/org/apache/camel/component/mqtt/MQTTConfigurationTest.java
@@ -33,4 +33,15 @@ public class MQTTConfigurationTest extends MQTTBaseTest {
         assertEquals(mqttEndpoint.getConfiguration().getSubscribeTopicName(), TEST_TOPIC);
         assertTrue(mqttEndpoint.getConfiguration().isByDefaultRetain());
     }
+
+    @Test
+    public void testWildcardSubscribeTopicConfiguration() throws Exception {
+        Endpoint endpoint = context.getEndpoint("mqtt:todo?byDefaultRetain=true&qualityOfService=exactlyOnce&publishTopicName="
+ TEST_TOPIC + "&subscribeTopicName=" + TEST_WILDCARD_TOPIC);
+        assertTrue("Endpoint not a MQTTEndpoint: " + endpoint, endpoint instanceof MQTTEndpoint);
+        MQTTEndpoint mqttEndpoint = (MQTTEndpoint) endpoint;
+        assertEquals(mqttEndpoint.getConfiguration().getQoS(), QoS.EXACTLY_ONCE);
+        assertEquals(mqttEndpoint.getConfiguration().getPublishTopicName(), TEST_TOPIC);
+        assertEquals(mqttEndpoint.getConfiguration().getSubscribeTopicName(), TEST_WILDCARD_TOPIC);
+        assertTrue(mqttEndpoint.getConfiguration().isByDefaultRetain());
+    }
 }


Mime
View raw message