activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1399151 - in /activemq/trunk: activemq-core/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java pom.xml
Date Wed, 17 Oct 2012 08:35:01 GMT
Author: davsclaus
Date: Wed Oct 17 08:35:00 2012
New Revision: 1399151

URL: http://svn.apache.org/viewvc?rev=1399151&view=rev
Log:
AMQ-4112: Upgraded to MQTT 1.4 and polished tests.

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
    activemq/trunk/pom.xml

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java?rev=1399151&r1=1399150&r2=1399151&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
Wed Oct 17 08:35:00 2012
@@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
 import static org.fusesource.hawtbuf.UTF8Buffer.utf8;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 
 public class MQTTTest {
@@ -59,6 +60,7 @@ public class MQTTTest {
         brokerService = new BrokerService();
         brokerService.setPersistent(false);
         brokerService.setAdvisorySupport(false);
+        brokerService.setUseJmx(false);
         this.numberOfMessages = 2000;
     }
 
@@ -86,7 +88,8 @@ public class MQTTTest {
             public void run() {
                 for (int i = 0; i < numberOfMessages; i++){
                     try {
-                        Message message = subscribeConnection.receive();
+                        Message message = subscribeConnection.receive(5, TimeUnit.SECONDS);
+                        assertNotNull("Should get a message", message);
                         message.ack();
                         latch.countDown();
                     } catch (Exception e) {
@@ -120,13 +123,13 @@ public class MQTTTest {
 
         connection.connect();
 
-
         Topic[] topics = {new Topic(utf8("foo"), QoS.AT_MOST_ONCE)};
         connection.subscribe(topics);
         for (int i = 0; i < numberOfMessages; i++) {
             String payload = "Test Message: " + i;
-            connection.publish("foo", payload.getBytes(), QoS.AT_MOST_ONCE, false);
-            Message message = connection.receive();
+            connection.publish("foo2", payload.getBytes(), QoS.AT_MOST_ONCE, false);
+            Message message = connection.receive(5, TimeUnit.SECONDS);
+            assertNotNull("Should get a message", message);
             assertEquals(payload, new String(message.getPayload()));
         }
         connection.disconnect();
@@ -147,7 +150,8 @@ public class MQTTTest {
         for (int i = 0; i < numberOfMessages; i++) {
             String payload = "Test Message: " + i;
             connection.publish("foo", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
-            Message message = connection.receive();
+            Message message = connection.receive(5, TimeUnit.SECONDS);
+            assertNotNull("Should get a message", message);
             message.ack();
             assertEquals(payload, new String(message.getPayload()));
         }
@@ -173,7 +177,9 @@ public class MQTTTest {
         for (int i = 0; i < numberOfMessages; i++) {
             String payload = "Test Message: " + i;
             pubConnection.publish("foo", payload.getBytes(), QoS.EXACTLY_ONCE, false);
-            Message message = subConnection.receive();
+            Message message = subConnection.receive(5, TimeUnit.SECONDS);
+            assertNotNull("Should get a message", message);
+            LOG.debug(payload);
             message.ack();
             assertEquals(payload, new String(message.getPayload()));
         }
@@ -204,7 +210,8 @@ public class MQTTTest {
         subConnection.subscribe(topics);
         for (int i = 0; i < 10; i++) {
             pubConnection.publish("foo", payload, QoS.AT_LEAST_ONCE, false);
-            Message message = subConnection.receive();
+            Message message = subConnection.receive(5, TimeUnit.SECONDS);
+            assertNotNull("Should get a message", message);
             message.ack();
             assertArrayEquals(payload, message.getPayload());
         }
@@ -232,7 +239,8 @@ public class MQTTTest {
         for (int i = 0; i < numberOfMessages; i++) {
             String payload = "Test Message: " + i;
             connection.publish("foo/bah", payload.getBytes(), QoS.AT_LEAST_ONCE, false);
-            ActiveMQMessage message = (ActiveMQMessage) consumer.receive();
+            ActiveMQMessage message = (ActiveMQMessage) consumer.receive(5000);
+            assertNotNull("Should get a message", message);
             ByteSequence bs = message.getContent();
             assertEquals(payload, new String(bs.data, bs.offset, bs.length));
         }
@@ -264,7 +272,8 @@ public class MQTTTest {
             String payload = "This is Test Message: " + i;
             TextMessage sendMessage = s.createTextMessage(payload);
             producer.send(sendMessage);
-            Message message = connection.receive();
+            Message message = connection.receive(5, TimeUnit.SECONDS);
+            assertNotNull("Should get a message", message);
             message.ack();
             assertEquals(payload, new String(message.getPayload()));
         }

Modified: activemq/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/pom.xml?rev=1399151&r1=1399150&r2=1399151&view=diff
==============================================================================
--- activemq/trunk/pom.xml (original)
+++ activemq/trunk/pom.xml Wed Oct 17 08:35:00 2012
@@ -86,7 +86,7 @@
     <karaf-version>2.2.9</karaf-version>
     <leveldbjni-version>1.3</leveldbjni-version>
     <log4j-version>1.2.17</log4j-version>
-    <mqtt-client-version>1.3</mqtt-client-version>
+    <mqtt-client-version>1.4</mqtt-client-version>
     <openjpa-version>1.2.0</openjpa-version>
     <opensymphony-version>2.4.2</opensymphony-version>
     <org-apache-derby-version>10.9.1.0</org-apache-derby-version>



Mime
View raw message