You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/02/26 20:16:07 UTC
svn commit: r1450366 - in
/activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt:
AbstractMQTTTest.java MQTTTest.java
Author: tabish
Date: Tue Feb 26 19:16:06 2013
New Revision: 1450366
URL: http://svn.apache.org/r1450366
Log:
Apply patch for: https://issues.apache.org/jira/browse/AMQ-4338
Modified:
activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/AbstractMQTTTest.java
activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
Modified: activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/AbstractMQTTTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/AbstractMQTTTest.java?rev=1450366&r1=1450365&r2=1450366&view=diff
==============================================================================
--- activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/AbstractMQTTTest.java (original)
+++ activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/AbstractMQTTTest.java Tue Feb 26 19:16:06 2013
@@ -16,6 +16,10 @@
*/
package org.apache.activemq.transport.mqtt;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.File;
import java.io.IOException;
import java.security.ProtectionDomain;
@@ -27,6 +31,7 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
+
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
@@ -36,8 +41,6 @@ import org.apache.activemq.util.ByteSequ
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.*;
-
public abstract class AbstractMQTTTest {
protected TransportConnector mqttConnector;
@@ -72,7 +75,7 @@ public abstract class AbstractMQTTTest {
}
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendAndReceiveMQTT() throws Exception {
addMQTTConnector();
brokerService.start();
@@ -85,6 +88,7 @@ public abstract class AbstractMQTTTest {
final CountDownLatch latch = new CountDownLatch(numberOfMessages);
Thread thread = new Thread(new Runnable() {
+ @Override
public void run() {
for (int i = 0; i < numberOfMessages; i++){
try {
@@ -115,7 +119,7 @@ public abstract class AbstractMQTTTest {
publishProvider.disconnect();
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendAtMostOnceReceiveExactlyOnce() throws Exception {
/**
* Although subscribing with EXACTLY ONCE, the message gets published
@@ -138,7 +142,7 @@ public abstract class AbstractMQTTTest {
provider.disconnect();
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendAtLeastOnceReceiveExactlyOnce() throws Exception {
addMQTTConnector();
brokerService.start();
@@ -156,7 +160,7 @@ public abstract class AbstractMQTTTest {
provider.disconnect();
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendAtLeastOnceReceiveAtMostOnce() throws Exception {
addMQTTConnector();
brokerService.start();
@@ -174,8 +178,7 @@ public abstract class AbstractMQTTTest {
provider.disconnect();
}
-
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendAndReceiveAtMostOnce() throws Exception {
addMQTTConnector();
brokerService.start();
@@ -193,7 +196,7 @@ public abstract class AbstractMQTTTest {
provider.disconnect();
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendAndReceiveAtLeastOnce() throws Exception {
addMQTTConnector();
brokerService.start();
@@ -211,7 +214,7 @@ public abstract class AbstractMQTTTest {
provider.disconnect();
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendAndReceiveExactlyOnce() throws Exception {
addMQTTConnector();
brokerService.start();
@@ -221,8 +224,7 @@ public abstract class AbstractMQTTTest {
final MQTTClientProvider subscriber = getMQTTClientProvider();
initializeConnection(subscriber);
-
- subscriber.subscribe("foo",EXACTLY_ONCE);
+ subscriber.subscribe("foo",EXACTLY_ONCE);
for (int i = 0; i < numberOfMessages; i++) {
String payload = "Test Message: " + i;
publisher.publish("foo", payload.getBytes(), EXACTLY_ONCE);
@@ -234,7 +236,7 @@ public abstract class AbstractMQTTTest {
publisher.disconnect();
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendAndReceiveLargeMessages() throws Exception {
byte[] payload = new byte[1024 * 32];
for (int i = 0; i < payload.length; i++){
@@ -261,8 +263,7 @@ public abstract class AbstractMQTTTest {
publisher.disconnect();
}
-
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendMQTTReceiveJMS() throws Exception {
addMQTTConnector();
TransportConnector openwireTransport = brokerService.addConnector("tcp://localhost:0");
@@ -272,7 +273,6 @@ public abstract class AbstractMQTTTest {
initializeConnection(provider);
final String DESTINATION_NAME = "foo.*";
-
ActiveMQConnection activeMQConnection = (ActiveMQConnection) new ActiveMQConnectionFactory(openwireTransport.getConnectUri()).createConnection();
activeMQConnection.start();
Session s = activeMQConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -288,12 +288,11 @@ public abstract class AbstractMQTTTest {
assertEquals(payload, new String(bs.data, bs.offset, bs.length));
}
-
activeMQConnection.close();
provider.disconnect();
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testSendJMSReceiveMQTT() throws Exception {
addMQTTConnector();
TransportConnector openwireTransport = brokerService.addConnector("tcp://localhost:0");
Modified: activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java?rev=1450366&r1=1450365&r2=1450366&view=diff
==============================================================================
--- activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java (original)
+++ activemq/trunk/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java Tue Feb 26 19:16:06 2013
@@ -16,16 +16,16 @@
*/
package org.apache.activemq.transport.mqtt;
+import static org.junit.Assert.assertTrue;
+
import org.apache.activemq.util.Wait;
import org.fusesource.mqtt.client.BlockingConnection;
import org.fusesource.mqtt.client.MQTT;
import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-
public class MQTTTest extends AbstractMQTTTest {
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testPingKeepsInactivityMonitorAlive() throws Exception {
addMQTTConnector();
brokerService.start();
@@ -45,7 +45,7 @@ public class MQTTTest extends AbstractMQ
connection.disconnect();
}
- @Test(timeout=30000)
+ @Test(timeout=300000)
public void testTurnOffInactivityMonitor()throws Exception{
addMQTTConnector("?transport.useInactivityMonitor=false");
brokerService.start();
@@ -65,7 +65,6 @@ public class MQTTTest extends AbstractMQ
connection.disconnect();
}
-
@Test(timeout=30000)
public void testDefaultKeepAliveWhenClientSpecifiesZero() throws Exception {
// default keep alive in milliseconds
@@ -85,17 +84,19 @@ public class MQTTTest extends AbstractMQ
}));
}
-
+ @Override
protected String getProtocolScheme() {
return "mqtt";
}
+ @Override
protected void addMQTTConnector() throws Exception {
addMQTTConnector("");
}
+ @Override
protected void addMQTTConnector(String config) throws Exception {
- mqttConnector= brokerService.addConnector(getProtocolScheme()+"://localhost:0" + config);
+ mqttConnector = brokerService.addConnector(getProtocolScheme()+"://localhost:0" + config);
}
@Override