broker/ServerIntegrationPahoTest: code formatter used
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
*
|
||||
* You may elect to redistribute this code under either of these licenses.
|
||||
*/
|
||||
|
||||
package io.moquette.server;
|
||||
|
||||
import io.moquette.server.config.IConfig;
|
||||
@@ -22,11 +23,9 @@ import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence;
|
||||
import org.junit.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ServerIntegrationPahoTest {
|
||||
@@ -114,7 +113,6 @@ public class ServerIntegrationPahoTest {
|
||||
assertEquals("/topic", m_messagesCollector.getTopic());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCleanSession_maintainClientSubscriptions() throws Exception {
|
||||
LOG.info("*** testCleanSession_maintainClientSubscriptions ***");
|
||||
@@ -134,7 +132,6 @@ public class ServerIntegrationPahoTest {
|
||||
assertEquals("/topic", m_messagesCollector.getTopic());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCleanSession_maintainClientSubscriptions_againstClientDestruction() throws Exception {
|
||||
LOG.info("*** testCleanSession_maintainClientSubscriptions_againstClientDestruction ***");
|
||||
@@ -152,9 +149,9 @@ public class ServerIntegrationPahoTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that after a client has connected with clean session false, subscribed
|
||||
* to some topic and exited, if it reconnects with clean session true, the m_server
|
||||
* correctly cleanup every previous subscription
|
||||
* Check that after a client has connected with clean session false, subscribed to some topic
|
||||
* and exited, if it reconnects with clean session true, the m_server correctly cleanup every
|
||||
* previous subscription
|
||||
*/
|
||||
@Test
|
||||
public void testCleanSession_correctlyClientSubscriptions() throws Exception {
|
||||
@@ -283,7 +280,6 @@ public class ServerIntegrationPahoTest {
|
||||
assertEquals("Hello MQTT", m_messagesCollector.waitMessage(1).toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkReceivePublishedMessage_after_a_reconnect_with_notCleanSession() throws Exception {
|
||||
LOG.info("*** checkReceivePublishedMessage_after_a_reconnect_with_notCleanSession ***");
|
||||
@@ -383,11 +379,9 @@ public class ServerIntegrationPahoTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* subscriber A connect and subscribe on "a/b" QoS 1
|
||||
* subscriber B connect and subscribe on "a/+" BUT with QoS 2
|
||||
* publisher connects and send a message "hello" on "a/b"
|
||||
* subscriber A must receive a notification with QoS1
|
||||
* subscriber B must receive a notification with QoS2
|
||||
* subscriber A connect and subscribe on "a/b" QoS 1 subscriber B connect and subscribe on "a/+"
|
||||
* BUT with QoS 2 publisher connects and send a message "hello" on "a/b" subscriber A must
|
||||
* receive a notification with QoS1 subscriber B must receive a notification with QoS2
|
||||
*/
|
||||
@Test
|
||||
public void checkSubscribersGetCorrectQosNotifications() throws Exception {
|
||||
@@ -410,7 +404,6 @@ public class ServerIntegrationPahoTest {
|
||||
subscriberB.connect();
|
||||
subscriberB.subscribe("a/+", 2);
|
||||
|
||||
|
||||
m_client.connect();
|
||||
m_client.publish("a/b", "Hello world MQTT!!".getBytes(), 2, false);
|
||||
|
||||
@@ -430,7 +423,8 @@ public class ServerIntegrationPahoTest {
|
||||
LOG.info("*** testSubcriptionDoesntStayActiveAfterARestart ***");
|
||||
String tmpDir = System.getProperty("java.io.tmpdir");
|
||||
// clientForSubscribe1 connect and subscribe to /topic QoS2
|
||||
MqttClientPersistence dsSubscriberA = new MqttDefaultFilePersistence(tmpDir + File.separator + "clientForSubscribe1");
|
||||
MqttClientPersistence dsSubscriberA = new MqttDefaultFilePersistence(
|
||||
tmpDir + File.separator + "clientForSubscribe1");
|
||||
|
||||
MqttClient clientForSubscribe1 = new MqttClient("tcp://localhost:1883", "clientForSubscribe1", dsSubscriberA);
|
||||
MessageCollector cbSubscriber1 = new MessageCollector();
|
||||
@@ -445,7 +439,8 @@ public class ServerIntegrationPahoTest {
|
||||
startServer();
|
||||
|
||||
// clientForSubscribe2 connect and subscribe to /topic QoS2
|
||||
MqttClientPersistence dsSubscriberB = new MqttDefaultFilePersistence(tmpDir + File.separator + "clientForSubscribe2");
|
||||
MqttClientPersistence dsSubscriberB = new MqttDefaultFilePersistence(
|
||||
tmpDir + File.separator + "clientForSubscribe2");
|
||||
MqttClient clientForSubscribe2 = new MqttClient("tcp://localhost:1883", "clientForSubscribe2", dsSubscriberB);
|
||||
MessageCollector cbSubscriber2 = new MessageCollector();
|
||||
clientForSubscribe2.setCallback(cbSubscriber2);
|
||||
@@ -453,7 +448,8 @@ public class ServerIntegrationPahoTest {
|
||||
clientForSubscribe2.subscribe("topic", 0);
|
||||
|
||||
// clientForPublish publish on /topic with QoS2 a message
|
||||
MqttClientPersistence dsSubscriberPUB = new MqttDefaultFilePersistence(tmpDir + File.separator + "clientForPublish");
|
||||
MqttClientPersistence dsSubscriberPUB = new MqttDefaultFilePersistence(
|
||||
tmpDir + File.separator + "clientForPublish");
|
||||
MqttClient clientForPublish = new MqttClient("tcp://localhost:1883", "clientForPublish", dsSubscriberPUB);
|
||||
clientForPublish.connect();
|
||||
clientForPublish.publish("topic", "Hello".getBytes(), 2, true);
|
||||
@@ -572,10 +568,9 @@ public class ServerIntegrationPahoTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"
|
||||
* 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 {
|
||||
@@ -605,9 +600,8 @@ public class ServerIntegrationPahoTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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 {
|
||||
@@ -634,7 +628,6 @@ public class ServerIntegrationPahoTest {
|
||||
assertNull(msg);
|
||||
}
|
||||
|
||||
|
||||
protected MqttClient createClient(String clientName, String storeSuffix) throws MqttException {
|
||||
return createClient(clientName, storeSuffix, null);
|
||||
}
|
||||
@@ -642,7 +635,8 @@ public class ServerIntegrationPahoTest {
|
||||
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);
|
||||
MqttClientPersistence dsClient = new MqttDefaultFilePersistence(
|
||||
tmpDir + File.separator + storeSuffix + clientName);
|
||||
MqttClient client = new MqttClient("tcp://localhost:1883", clientName, dsClient);
|
||||
if (cb != null) {
|
||||
client.setCallback(cb);
|
||||
|
||||
Reference in New Issue
Block a user