broker/ServerIntegrationFuseTest: code formatter used

This commit is contained in:
Andreas Mager
2017-02-01 17:13:42 +01:00
parent 4e9e7a8bc1
commit 139db5e5b8
@@ -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;
@@ -23,11 +24,9 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
@@ -35,6 +34,7 @@ import static org.junit.Assert.*;
* @author andrea * @author andrea
*/ */
public class ServerIntegrationFuseTest { public class ServerIntegrationFuseTest {
private static final Logger LOG = LoggerFactory.getLogger(ServerIntegrationPahoTest.class); private static final Logger LOG = LoggerFactory.getLogger(ServerIntegrationPahoTest.class);
Server m_server; Server m_server;
@@ -42,7 +42,7 @@ public class ServerIntegrationFuseTest {
BlockingConnection m_subscriber; BlockingConnection m_subscriber;
BlockingConnection m_publisher; BlockingConnection m_publisher;
IConfig m_config; IConfig m_config;
protected void startServer() throws IOException { protected void startServer() throws IOException {
m_server = new Server(); m_server = new Server();
final Properties configProps = IntegrationUtils.prepareTestProperties(); final Properties configProps = IntegrationUtils.prepareTestProperties();
@@ -63,7 +63,7 @@ public class ServerIntegrationFuseTest {
if (m_subscriber != null) { if (m_subscriber != null) {
m_subscriber.disconnect(); m_subscriber.disconnect();
} }
if (m_publisher != null) { if (m_publisher != null) {
m_publisher.disconnect(); m_publisher.disconnect();
} }
@@ -75,31 +75,31 @@ public class ServerIntegrationFuseTest {
@Test @Test
public void checkWillTestamentIsPublishedOnConnectionKill_noRetain() throws Exception { public void checkWillTestamentIsPublishedOnConnectionKill_noRetain() throws Exception {
LOG.info("checkWillTestamentIsPublishedOnConnectionKill_noRetain"); LOG.info("checkWillTestamentIsPublishedOnConnectionKill_noRetain");
String willTestamentTopic = "/will/test"; String willTestamentTopic = "/will/test";
String willTestamentMsg = "Bye bye"; String willTestamentMsg = "Bye bye";
MQTT mqtt = new MQTT(); MQTT mqtt = new MQTT();
mqtt.setHost("localhost", 1883); mqtt.setHost("localhost", 1883);
mqtt.setClientId("WillTestamentPublisher"); mqtt.setClientId("WillTestamentPublisher");
mqtt.setWillRetain(false); mqtt.setWillRetain(false);
mqtt.setWillMessage(willTestamentMsg); mqtt.setWillMessage(willTestamentMsg);
mqtt.setWillTopic(willTestamentTopic); mqtt.setWillTopic(willTestamentTopic);
m_publisher = mqtt.blockingConnection(); m_publisher = mqtt.blockingConnection();
m_publisher.connect(); m_publisher.connect();
m_mqtt.setHost("localhost", 1883); m_mqtt.setHost("localhost", 1883);
m_mqtt.setCleanSession(false); m_mqtt.setCleanSession(false);
m_mqtt.setClientId("Subscriber"); m_mqtt.setClientId("Subscriber");
m_subscriber = m_mqtt.blockingConnection(); m_subscriber = m_mqtt.blockingConnection();
m_subscriber.connect(); m_subscriber.connect();
Topic[] topics = new Topic[]{new Topic(willTestamentTopic, QoS.AT_MOST_ONCE)}; Topic[] topics = new Topic[]{new Topic(willTestamentTopic, QoS.AT_MOST_ONCE)};
m_subscriber.subscribe(topics); m_subscriber.subscribe(topics);
//Exercise, kill the publisher connection // Exercise, kill the publisher connection
m_publisher.kill(); m_publisher.kill();
//Verify, that the testament is fired // Verify, that the testament is fired
Message msg = m_subscriber.receive(500, TimeUnit.MILLISECONDS); Message msg = m_subscriber.receive(500, TimeUnit.MILLISECONDS);
assertNotNull("We should get notified with 'Will' message", msg); assertNotNull("We should get notified with 'Will' message", msg);
msg.ack(); msg.ack();