From 2b77aa1b5470551488d48d905aefd4df0a31298e Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Thu, 30 Aug 2012 18:46:54 +0200 Subject: [PATCH 1/3] Added first try to use Fuse source MQTT client in test units --- parser/pom.xml | 27 +++++++++++++--- .../server/ServerIntegrationTest.java | 31 ++++++++++++++++--- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/parser/pom.xml b/parser/pom.xml index 536ad89e..413622ea 100644 --- a/parser/pom.xml +++ b/parser/pom.xml @@ -58,6 +58,14 @@ 1.9.0 test + + + org.fusesource.mqtt-client + mqtt-client + + 1.3 + test + @@ -101,10 +109,21 @@ - + --> + + diff --git a/parser/src/test/java/org/dna/mqtt/moquette/server/ServerIntegrationTest.java b/parser/src/test/java/org/dna/mqtt/moquette/server/ServerIntegrationTest.java index 01b952cd..49ed6b17 100644 --- a/parser/src/test/java/org/dna/mqtt/moquette/server/ServerIntegrationTest.java +++ b/parser/src/test/java/org/dna/mqtt/moquette/server/ServerIntegrationTest.java @@ -6,6 +6,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.dna.mqtt.moquette.client.Client; import org.dna.mqtt.moquette.client.IPublishCallback; +import org.fusesource.mqtt.client.*; import org.junit.After; import static org.junit.Assert.*; import org.junit.Before; @@ -40,6 +41,26 @@ public class ServerIntegrationTest { } } + @Ignore + public void testSubscribe_FSClient() throws Exception { +// startServer(); + MQTT mqtt = new MQTT(); +// mqtt.setHost("localhost", Server.PORT); + mqtt.setHost("test.mosquitto.org", Server.PORT); + mqtt.setClientId("TestClient"); + FutureConnection connection = mqtt.futureConnection(); + connection.connect().await(); + + Topic[] topics = {new Topic("/topic", QoS.AT_MOST_ONCE)}; + Future futSub = connection.subscribe(topics); + + connection.publish("/topic", "Test my payload".getBytes(), QoS.AT_MOST_ONCE, false).await(); + + byte[] qoses = futSub.await(); + assertEquals(1, qoses.length); + connection.disconnect().await(); + } + @Test public void testSubscribe() throws IOException, InterruptedException { @@ -47,20 +68,20 @@ public class ServerIntegrationTest { Client client = new Client("localhost", Server.PORT); // Client client = new Client("test.mosquitto.org", 1883); client.connect(); - - + + client.subscribe("/topic", new IPublishCallback() { public void published(String topic, byte[] message) { received = true; } }); - + client.publish("/topic", "Test my payload".getBytes()); - + client.close(); client.shutdown(); - + assertTrue(received); } From 6ab45608871fa09dc3fc0b4c18f7b69f1605fd85 Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Thu, 30 Aug 2012 18:53:49 +0200 Subject: [PATCH 2/3] Forced to use hawtdb 1.9 else it includes version 1.4 that's not API compliant --- parser/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/parser/pom.xml b/parser/pom.xml index 413622ea..9d9b0225 100644 --- a/parser/pom.xml +++ b/parser/pom.xml @@ -66,6 +66,12 @@ 1.3 test + + + org.fusesource.hawtbuf + hawtbuf + 1.9 + From 043b1b2095576a2e07d01ba03001fe7a1038a902 Mon Sep 17 00:00:00 2001 From: "selva.andre" Date: Thu, 30 Aug 2012 18:59:37 +0200 Subject: [PATCH 3/3] Minor change --- .../org/dna/mqtt/moquette/server/ServerIntegrationTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/parser/src/test/java/org/dna/mqtt/moquette/server/ServerIntegrationTest.java b/parser/src/test/java/org/dna/mqtt/moquette/server/ServerIntegrationTest.java index 49ed6b17..c5b1ddad 100644 --- a/parser/src/test/java/org/dna/mqtt/moquette/server/ServerIntegrationTest.java +++ b/parser/src/test/java/org/dna/mqtt/moquette/server/ServerIntegrationTest.java @@ -41,12 +41,11 @@ public class ServerIntegrationTest { } } - @Ignore + @Test public void testSubscribe_FSClient() throws Exception { // startServer(); MQTT mqtt = new MQTT(); -// mqtt.setHost("localhost", Server.PORT); - mqtt.setHost("test.mosquitto.org", Server.PORT); + mqtt.setHost("localhost", Server.PORT); mqtt.setClientId("TestClient"); FutureConnection connection = mqtt.futureConnection(); connection.connect().await();