broker/test/ServerIntegrationEmbeddedPublishTest: code formatter used

This commit is contained in:
Andreas Mager
2017-02-01 17:13:42 +01:00
parent 7b57f04db9
commit 4e9e7a8bc1
@@ -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.netty.MessageBuilder; import io.moquette.server.netty.MessageBuilder;
@@ -28,11 +29,9 @@ import org.junit.BeforeClass;
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.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 ServerIntegrationEmbeddedPublishTest { public class ServerIntegrationEmbeddedPublishTest {
@@ -89,12 +88,8 @@ public class ServerIntegrationEmbeddedPublishTest {
} }
private void internalPublishToWithQosAndRetained(String topic, MqttQoS qos, boolean retained) { private void internalPublishToWithQosAndRetained(String topic, MqttQoS qos, boolean retained) {
MqttPublishMessage message = MessageBuilder.publish() MqttPublishMessage message = MessageBuilder.publish().topicName(topic).retained(retained).qos(qos)
.topicName(topic) .payload("Hello world MQTT!!".getBytes()).build();
.retained(retained)
.qos(qos)
.payload("Hello world MQTT!!".getBytes())
.build();
m_server.internalPublish(message, "INTRPUBL"); m_server.internalPublish(message, "INTRPUBL");
} }
@@ -115,7 +110,7 @@ public class ServerIntegrationEmbeddedPublishTest {
} }
private void verifyMessageIsReceivedSuccessfully() throws Exception { private void verifyMessageIsReceivedSuccessfully() throws Exception {
//check in 2 seconds // check in 2 seconds
MqttMessage msg = m_callback.waitMessage(2); MqttMessage msg = m_callback.waitMessage(2);
assertNotNull(msg); assertNotNull(msg);
assertEquals("Hello world MQTT!!", new String(msg.getPayload())); assertEquals("Hello world MQTT!!", new String(msg.getPayload()));
@@ -125,11 +120,11 @@ public class ServerIntegrationEmbeddedPublishTest {
public void testClientSubscribeAfterNotRetainedQoS0IsSent() throws Exception { public void testClientSubscribeAfterNotRetainedQoS0IsSent() throws Exception {
LOG.info("*** testClientSubscribeAfterNotRetainedQoS0IsSent ***"); LOG.info("*** testClientSubscribeAfterNotRetainedQoS0IsSent ***");
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_MOST_ONCE, false); internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_MOST_ONCE, false);
subscribeToWithQos("/topic", 0); subscribeToWithQos("/topic", 0);
//Verify // Verify
verifyNoMessageIsReceived(); verifyNoMessageIsReceived();
} }
@@ -139,10 +134,10 @@ public class ServerIntegrationEmbeddedPublishTest {
subscribeToWithQos("/topic", 0); subscribeToWithQos("/topic", 0);
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_MOST_ONCE, false); internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_MOST_ONCE, false);
//Verify // Verify
verifyMessageIsReceivedSuccessfully(); verifyMessageIsReceivedSuccessfully();
} }
@@ -152,10 +147,10 @@ public class ServerIntegrationEmbeddedPublishTest {
subscribeToWithQos("/topic", 0); subscribeToWithQos("/topic", 0);
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_MOST_ONCE, true); internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_MOST_ONCE, true);
//Verify // Verify
verifyMessageIsReceivedSuccessfully(); verifyMessageIsReceivedSuccessfully();
} }
@@ -163,12 +158,12 @@ public class ServerIntegrationEmbeddedPublishTest {
public void testClientSubscribeAfterRetainedQoS0IsSent() throws Exception { public void testClientSubscribeAfterRetainedQoS0IsSent() throws Exception {
LOG.info("*** testClientSubscribeAfterRetainedQoS0IsSent ***"); LOG.info("*** testClientSubscribeAfterRetainedQoS0IsSent ***");
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_MOST_ONCE, true); internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_MOST_ONCE, true);
//LOG.info("** post internalPublish **"); // LOG.info("** post internalPublish **");
subscribeToWithQos("/topic", 0); subscribeToWithQos("/topic", 0);
//Verify // Verify
verifyNoMessageIsReceived(); verifyNoMessageIsReceived();
} }
@@ -178,10 +173,10 @@ public class ServerIntegrationEmbeddedPublishTest {
subscribeToWithQos("/topic", 1); subscribeToWithQos("/topic", 1);
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_LEAST_ONCE, false); internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_LEAST_ONCE, false);
//Verify // Verify
verifyMessageIsReceivedSuccessfully(); verifyMessageIsReceivedSuccessfully();
} }
@@ -189,11 +184,11 @@ public class ServerIntegrationEmbeddedPublishTest {
public void testClientSubscribeAfterNotRetainedQoS1IsSent() throws Exception { public void testClientSubscribeAfterNotRetainedQoS1IsSent() throws Exception {
LOG.info("*** testClientSubscribeAfterNotRetainedQoS1IsSent ***"); LOG.info("*** testClientSubscribeAfterNotRetainedQoS1IsSent ***");
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_LEAST_ONCE, false); internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_LEAST_ONCE, false);
subscribeToWithQos("/topic", 1); subscribeToWithQos("/topic", 1);
//Verify // Verify
verifyNoMessageIsReceived(); verifyNoMessageIsReceived();
} }
@@ -203,10 +198,10 @@ public class ServerIntegrationEmbeddedPublishTest {
subscribeToWithQos("/topic", 1); subscribeToWithQos("/topic", 1);
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_LEAST_ONCE, true); internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_LEAST_ONCE, true);
//Verify // Verify
verifyMessageIsReceivedSuccessfully(); verifyMessageIsReceivedSuccessfully();
} }
@@ -214,12 +209,12 @@ public class ServerIntegrationEmbeddedPublishTest {
public void testClientSubscribeAfterRetainedQoS1IsSent() throws Exception { public void testClientSubscribeAfterRetainedQoS1IsSent() throws Exception {
LOG.info("*** testClientSubscribeAfterRetainedQoS0IsSent ***"); LOG.info("*** testClientSubscribeAfterRetainedQoS0IsSent ***");
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_LEAST_ONCE, true); internalPublishToWithQosAndRetained("/topic", MqttQoS.AT_LEAST_ONCE, true);
subscribeToWithQos("/topic", MqttQoS.AT_LEAST_ONCE.value()); subscribeToWithQos("/topic", MqttQoS.AT_LEAST_ONCE.value());
LOG.info("** After subscribe **"); LOG.info("** After subscribe **");
//Verify // Verify
verifyMessageIsReceivedSuccessfully(); verifyMessageIsReceivedSuccessfully();
LOG.info("** Post verify **"); LOG.info("** Post verify **");
} }
@@ -230,10 +225,10 @@ public class ServerIntegrationEmbeddedPublishTest {
subscribeToWithQos("/topic", 2); subscribeToWithQos("/topic", 2);
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.EXACTLY_ONCE, false); internalPublishToWithQosAndRetained("/topic", MqttQoS.EXACTLY_ONCE, false);
//Verify // Verify
verifyMessageIsReceivedSuccessfully(); verifyMessageIsReceivedSuccessfully();
} }
@@ -241,11 +236,11 @@ public class ServerIntegrationEmbeddedPublishTest {
public void testClientSubscribeAfterNotRetainedQoS2IsSent() throws Exception { public void testClientSubscribeAfterNotRetainedQoS2IsSent() throws Exception {
LOG.info("*** testClientSubscribeAfterNotRetainedQoS2IsSent ***"); LOG.info("*** testClientSubscribeAfterNotRetainedQoS2IsSent ***");
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.EXACTLY_ONCE, false); internalPublishToWithQosAndRetained("/topic", MqttQoS.EXACTLY_ONCE, false);
subscribeToWithQos("/topic", 2); subscribeToWithQos("/topic", 2);
//Verify // Verify
verifyNoMessageIsReceived(); verifyNoMessageIsReceived();
} }
@@ -255,10 +250,10 @@ public class ServerIntegrationEmbeddedPublishTest {
subscribeToWithQos("/topic", 2); subscribeToWithQos("/topic", 2);
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.EXACTLY_ONCE, true); internalPublishToWithQosAndRetained("/topic", MqttQoS.EXACTLY_ONCE, true);
//Verify // Verify
verifyMessageIsReceivedSuccessfully(); verifyMessageIsReceivedSuccessfully();
} }
@@ -266,11 +261,11 @@ public class ServerIntegrationEmbeddedPublishTest {
public void testClientSubscribeAfterRetainedQoS2IsSent() throws Exception { public void testClientSubscribeAfterRetainedQoS2IsSent() throws Exception {
LOG.info("*** testClientSubscribeAfterRetainedQoS2IsSent ***"); LOG.info("*** testClientSubscribeAfterRetainedQoS2IsSent ***");
//Exercise // Exercise
internalPublishToWithQosAndRetained("/topic", MqttQoS.EXACTLY_ONCE, true); internalPublishToWithQosAndRetained("/topic", MqttQoS.EXACTLY_ONCE, true);
subscribeToWithQos("/topic", 2); subscribeToWithQos("/topic", 2);
//Verify // Verify
verifyMessageIsReceivedSuccessfully(); verifyMessageIsReceivedSuccessfully();
} }
@@ -283,8 +278,8 @@ public class ServerIntegrationEmbeddedPublishTest {
internalPublishToWithQosAndRetained("foo", MqttQoS.AT_MOST_ONCE, false); internalPublishToWithQosAndRetained("foo", MqttQoS.AT_MOST_ONCE, false);
//verifyMessageIsReceivedSuccessfully(); // verifyMessageIsReceivedSuccessfully();
//m_subscriber.receive(2, TimeUnit.MILLISECONDS); // m_subscriber.receive(2, TimeUnit.MILLISECONDS);
MqttMessage message = m_callback.waitMessage(1); MqttMessage message = m_callback.waitMessage(1);
assertTrue(message == null); assertTrue(message == null);
} }