broker/ServerIntegrationPahoTest: code formatter used

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