Fixed leaks
This commit is contained in:
@@ -192,187 +192,4 @@ public class ServerIntegrationPahoTest {
|
||||
MqttMessage messageOnB = cbSubscriber2.waitMessage(1);
|
||||
assertEquals("Hello", new String(messageOnB.getPayload(), UTF_8));
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testForceClientDisconnection_issue116() throws Exception {
|
||||
// LOG.info("*** testForceClientDisconnection_issue118 ***");
|
||||
// MessageCollector cbSubscriber1 = new MessageCollector();
|
||||
// MqttClient clientXA = createClient("subscriber", "X", cbSubscriber1);
|
||||
// LOG.info("Connected 'subscriber' first time");
|
||||
// clientXA.subscribe("topic", 0);
|
||||
// LOG.info("Subscribed 'topic' from 'subscriber' first time");
|
||||
//
|
||||
// MqttClient clientXB = createClient("publisher", "X");
|
||||
// LOG.info("Connected 'publisher' first time");
|
||||
// clientXB.publish("topic", "Hello".getBytes(), 2, false);
|
||||
// LOG.info("Published on 'topic' from 'publisher' first time");
|
||||
//
|
||||
// LOG.info("Creating second new 'subscriber'");
|
||||
// MessageCollector cbSubscriber2 = new MessageCollector();
|
||||
// MqttClient clientYA = createClient("subscriber", "Y", cbSubscriber2);
|
||||
// LOG.info("Connected 'subscriber' second time");
|
||||
// clientYA.subscribe("topic", 0);
|
||||
//
|
||||
// MqttClient clientYB = createClient("publisher", "Y");
|
||||
// clientYB.publish("topic", "Hello 2".getBytes(), 2, true);
|
||||
//
|
||||
// // Verify that the second subscriber client get notified and not the first.
|
||||
// assertTrue(cbSubscriber1.connectionLost());
|
||||
// assertEquals("Hello 2", new String(cbSubscriber2.waitMessage(1).getPayload()));
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testConnectSubPub_cycle_getTimeout_on_second_disconnect_issue142() throws Exception {
|
||||
// LOG.info("*** testConnectSubPub_cycle_getTimeout_on_second_disconnect_issue142 ***");
|
||||
// MqttConnectOptions options = new MqttConnectOptions();
|
||||
// options.setCleanSession(false);
|
||||
// m_client.connect(options);
|
||||
// m_client.subscribe("/topic", 0);
|
||||
// m_client.publish("/topic", "Hello".getBytes(), 0, true);
|
||||
// m_client.disconnect();
|
||||
//
|
||||
// // second loop
|
||||
// m_client.connect(options);
|
||||
// m_client.subscribe("/topic", 0);
|
||||
// m_client.publish("/topic", "Hello".getBytes(), 0, true);
|
||||
// m_client.disconnect(); // this should give timeout
|
||||
//
|
||||
// assertFalse("after a disconnect the client should be disconnected", m_client.isConnected());
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void checkReplayofStoredPublishResumeAfter_a_disconnect_cleanSessionFalseQoS1() throws Exception {
|
||||
// LOG.info("*** checkReplayofStoredPublishResumeAfter_a_disconnect_cleanSessionFalseQoS1 ***");
|
||||
// // MessageCollector m_messagesCollector = new MessageCollector();
|
||||
// // m_client.setCallback(m_messagesCollector);
|
||||
// m_publisher.connect();
|
||||
//
|
||||
// MqttConnectOptions options = new MqttConnectOptions();
|
||||
// options.setCleanSession(false);
|
||||
// m_client.connect(options);
|
||||
// m_client.subscribe("/topic", 1);
|
||||
//
|
||||
// // force the publisher to send
|
||||
// m_publisher.publish("/topic", "Hello world MQTT!!-1".getBytes(), 1, false);
|
||||
//
|
||||
// // read the first message and drop the connection
|
||||
// MqttMessage msg = m_messagesCollector.waitMessage(1);
|
||||
// assertEquals("Hello world MQTT!!-1", new String(msg.getPayload()));
|
||||
// m_client.disconnect();
|
||||
//
|
||||
// m_publisher.publish("/topic", "Hello world MQTT!!-2".getBytes(), 1, false);
|
||||
// m_publisher.publish("/topic", "Hello world MQTT!!-3".getBytes(), 1, false);
|
||||
//
|
||||
// // reconnect and expect to receive the hello 2 message
|
||||
// m_client.connect(options);
|
||||
// msg = m_messagesCollector.waitMessage(1);
|
||||
// assertEquals("Hello world MQTT!!-2", new String(msg.getPayload()));
|
||||
//
|
||||
// msg = m_messagesCollector.waitMessage(1);
|
||||
// assertEquals("Hello world MQTT!!-3", new String(msg.getPayload()));
|
||||
// m_client.disconnect();
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void checkReplayStoredPublish_forNoCleanSession_qos1() throws Exception {
|
||||
// LOG.info("*** checkReplayStoredPublish_forNoCleanSession_qos1 ***");
|
||||
// MessageCollector messagesCollector = new MessageCollector();
|
||||
// m_client.setCallback(messagesCollector);
|
||||
// m_publisher.connect();
|
||||
//
|
||||
// MqttConnectOptions options = new MqttConnectOptions();
|
||||
// options.setCleanSession(false);
|
||||
// m_client.connect(options);
|
||||
// m_client.subscribe("/topic", 1);
|
||||
// m_client.disconnect();
|
||||
//
|
||||
// // force the publisher to send
|
||||
// m_publisher.publish("/topic", "Hello world MQTT!!-1".getBytes(), 1, false);
|
||||
//
|
||||
// // reconnect and expect to receive the hello 2 message
|
||||
// m_client.connect(options);
|
||||
// m_client.subscribe("/topic", 1);
|
||||
// MqttMessage msg = messagesCollector.waitMessage(1);
|
||||
// assertNotNull(msg);
|
||||
// assertEquals("Hello world MQTT!!-1", new String(msg.getPayload()));
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * subscriber connect and subscribe on "topic" subscriber disconnects publisher connects and
|
||||
// * send two message "hello1" "hello2" to "topic" subscriber connects again and receive "hello1"
|
||||
// * "hello2"
|
||||
// */
|
||||
// @Test
|
||||
// public void checkQoS2SubscriberDisconnectReceivePersistedPublishes() throws Exception {
|
||||
// LOG.info("*** checkQoS2SubscriberDisconnectReceivePersistedPublishes ***");
|
||||
// MessageCollector messagesCollector = new MessageCollector();
|
||||
// m_client.setCallback(messagesCollector);
|
||||
// MqttConnectOptions options = new MqttConnectOptions();
|
||||
// options.setCleanSession(false);
|
||||
// m_client.connect(options);
|
||||
// m_client.subscribe("topic", 2);
|
||||
// m_client.disconnect();
|
||||
//
|
||||
// m_publisher.connect();
|
||||
// m_publisher.publish("topic", "Hello1".getBytes(), 2, true);
|
||||
// m_publisher.publish("topic", "Hello2".getBytes(), 2, true);
|
||||
// m_publisher.disconnect();
|
||||
//
|
||||
// // subscriber reconnects
|
||||
// m_client.connect(options);
|
||||
// // subscriber should receive the 2 messages missed
|
||||
// MqttMessage msg = messagesCollector.waitMessage(1);
|
||||
// assertNotNull(msg);
|
||||
// assertEquals("Hello1", new String(msg.getPayload()));
|
||||
// msg = messagesCollector.waitMessage(1);
|
||||
// assertNotNull(msg);
|
||||
// assertEquals("Hello2", new String(msg.getPayload()));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * subscriber connect and subscribe on "a/b" QoS 1 and "a/+" QoS 2 publisher connects and send a
|
||||
// * message "hello" on "a/b" subscriber must receive only a single message not twice
|
||||
// */
|
||||
// @Test
|
||||
// public void checkSinglePublishOnOverlappingSubscriptions() throws Exception {
|
||||
// LOG.info("*** checkSinglePublishOnOverlappingSubscriptions ***");
|
||||
// MessageCollector messagesCollector = new MessageCollector();
|
||||
// m_client.setCallback(messagesCollector);
|
||||
// m_publisher.connect();
|
||||
//
|
||||
// MqttConnectOptions options = new MqttConnectOptions();
|
||||
// options.setCleanSession(false);
|
||||
// m_client.connect(options);
|
||||
// m_client.subscribe("a/+", 2);
|
||||
// m_client.subscribe("a/b", 1);
|
||||
//
|
||||
// // force the publisher to send
|
||||
// m_publisher.publish("a/b", "Hello world MQTT!!".getBytes(), 1, false);
|
||||
//
|
||||
// // reconnect and expect to receive the hello 2 message
|
||||
// MqttMessage msg = messagesCollector.waitMessage(1);
|
||||
// assertEquals("Hello world MQTT!!", new String(msg.getPayload()));
|
||||
//
|
||||
// // try to listen a second publish
|
||||
// msg = messagesCollector.waitMessage(1);
|
||||
// assertNull(msg);
|
||||
// }
|
||||
|
||||
protected MqttClient createClient(String clientName, String storeSuffix) throws MqttException {
|
||||
return createClient(clientName, storeSuffix, null);
|
||||
}
|
||||
|
||||
protected MqttClient createClient(String clientName, String storeSuffix, MessageCollector cb) throws MqttException {
|
||||
String tmpDir = System.getProperty("java.io.tmpdir");
|
||||
// clientX connect and subscribe to /topic QoS2
|
||||
MqttClientPersistence dsClient = new MqttDefaultFilePersistence(
|
||||
tmpDir + File.separator + storeSuffix + clientName);
|
||||
MqttClient client = new MqttClient("tcp://localhost:1883", clientName, dsClient);
|
||||
if (cb != null) {
|
||||
client.setCallback(cb);
|
||||
}
|
||||
client.connect();
|
||||
return client;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user