1+ /*******************************************************************************
2+ * Copyright (c) 2009, 2014 IBM Corp.
3+ *
4+ * All rights reserved. This program and the accompanying materials
5+ * are made available under the terms of the Eclipse Public License v1.0
6+ * and Eclipse Distribution License v1.0 which accompany this distribution.
7+ *
8+ * The Eclipse Public License is available at
9+ * http://www.eclipse.org/legal/epl-v10.html
10+ * and the Eclipse Distribution License is available at
11+ * http://www.eclipse.org/org/documents/edl-v10.php.
12+ *
13+ *******************************************************************************/
14+
115package org .eclipse .paho .client .mqttv3 .test .connectionLoss ;
216
317import java .util .Date ;
1327import org .eclipse .paho .client .mqttv3 .MqttException ;
1428import org .eclipse .paho .client .mqttv3 .MqttMessage ;
1529import org .eclipse .paho .client .mqttv3 .persist .MqttDefaultFilePersistence ;
30+ import org .eclipse .paho .client .mqttv3 .test .ManualTest ;
1631import org .junit .Assert ;
1732import org .junit .Test ;
33+ import org .junit .experimental .categories .Category ;
1834
19- public class ConnectionLossTest implements MqttCallback
35+ /**
36+ * These tests verify whether paho can successfully detect a loss of connection with a broker.
37+ *
38+ * >> The tests MUST BE run manually and they WILL FAIL in an automated test environment. <<
39+ * The pom.xml of the test project, all tests categorized as ManualTests are excluded from the execution.
40+ *
41+ * The tests will print a messages in the console notifying the operator when to "unplug" the internet connection of the test machine.
42+ *
43+ * @author mcarrer
44+ */
45+ @ Category (ManualTest .class )
46+ public class ConnectionLossManualTest implements MqttCallback
2047{
21- static final Class <?> cclass = ConnectionLossTest .class ;
48+ static final Class <?> cclass = ConnectionLossManualTest .class ;
2249 private static final String className = cclass .getName ();
2350 private static final Logger log = Logger .getLogger (className );
2451
@@ -28,7 +55,11 @@ public class ConnectionLossTest implements MqttCallback
2855 private char [] password = "password" .toCharArray ();
2956 private String clientId = "device-client-id" ;
3057 private String message = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" ;
31-
58+
59+ /**
60+ * Tests whether paho can detect a connection loss with the server even if it has outbound activity by publishing messages with QoS 0.
61+ * @throws Exception
62+ */
3263 @ Test
3364 public void testConnectionLossWhilePublishingQos0 ()
3465 throws Exception
@@ -79,6 +110,10 @@ public void run() {
79110 }
80111
81112
113+ /**
114+ * Tests whether paho can detect a connection loss with the server even if it has outbound activity by publishing messages with QoS 1.
115+ * @throws Exception
116+ */
82117 @ Test
83118 public void testConnectionLossWhilePublishingQos1 ()
84119 throws Exception
@@ -130,6 +165,10 @@ public void run() {
130165 }
131166
132167
168+ /**
169+ * Tests whether paho can detect a connection loss with the server even if it has outbound activity by publishing messages with QoS 2.
170+ * @throws Exception
171+ */
133172 @ Test
134173 public void testConnectionLossWhilePublishingQos2 ()
135174 throws Exception
@@ -180,6 +219,10 @@ public void run() {
180219 }
181220
182221
222+ /**
223+ * Tests whether async paho can detect a connection loss with the server even if it has outbound activity by publishing messages with QoS 1.
224+ * @throws Exception
225+ */
183226 @ Test
184227 public void testConnectionLossWhilePublishingQos1Async ()
185228 throws Exception
@@ -239,6 +282,10 @@ public void run() {
239282 }
240283
241284
285+ /**
286+ * Tests whether paho keeps the connection alive for 10 keep alive intervals while publishing messages with QoS 0.
287+ * @throws Exception
288+ */
242289 @ Test
243290 public void testKeepConnectionOpenWhilePublishingQos0 ()
244291 throws Exception
@@ -279,6 +326,10 @@ public void run() {
279326 }
280327
281328
329+ /**
330+ * Tests whether paho keeps the connection alive for 10 keep alive in idle state.
331+ * @throws Exception
332+ */
282333 @ Test
283334 public void testKeepConnectionOpenIdle ()
284335 throws Exception
0 commit comments