Skip to content

Commit 1850c34

Browse files
committed
Merge pull request #187 from jpwsutton/develop
Improving Automatic Reconnect & Offline buffering tests
2 parents a6887fd + 39dd490 commit 1850c34

3 files changed

Lines changed: 383 additions & 387 deletions

File tree

org.eclipse.paho.client.mqttv3.test/src/test/java/org/eclipse/paho/client/mqttv3/test/automaticReconnect/AutomaticReconnectTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ public static void setUpBeforeClass() throws Exception{
3737
String methodName = Utility.getMethodName();
3838
LoggingUtilities.banner(log, cclass, methodName);
3939
serverURI = TestProperties.getServerURI();
40-
proxy = new ConnectionManipulationProxyServer(serverURI.getHost(), serverURI.getPort(), 4242);
40+
// Use 0 for the first time.
41+
proxy = new ConnectionManipulationProxyServer(serverURI.getHost(), serverURI.getPort(), 0);
4142
proxy.startProxy();
43+
while(!proxy.isPortSet()){
44+
Thread.sleep(0);
45+
}
46+
log.log(Level.INFO, "Proxy Started, port set to: " + proxy.getLocalPort());
4247
} catch (Exception exception) {
4348
log.log(Level.SEVERE, "caught exception:", exception);
4449
throw exception;
@@ -65,7 +70,7 @@ public void testAutomaticReconnectAfterDisconnect() throws Exception{
6570
MqttConnectOptions options = new MqttConnectOptions();
6671
options.setCleanSession(true);
6772
options.setAutomaticReconnect(true);
68-
final MqttClient client = new MqttClient("tcp://localhost:4242", clientId, DATA_STORE);
73+
final MqttClient client = new MqttClient("tcp://localhost:" + proxy.getLocalPort(), clientId, DATA_STORE);
6974

7075
proxy.enableProxy();
7176
client.connect(options);
@@ -110,7 +115,7 @@ public void testManualReconnectAfterDisconnect() throws Exception {
110115
options.setCleanSession(true);
111116
options.setAutomaticReconnect(true);
112117

113-
final MqttClient client = new MqttClient("tcp://localhost:4242", clientId, DATA_STORE);
118+
final MqttClient client = new MqttClient("tcp://localhost:" + proxy.getLocalPort(), clientId, DATA_STORE);
114119

115120
proxy.enableProxy();
116121
client.connect(options);
@@ -148,7 +153,7 @@ public void testNoAutomaticReconnectWithNoInitialConnect() throws Exception {
148153
options.setCleanSession(true);
149154
options.setAutomaticReconnect(true);
150155
options.setConnectionTimeout(15);
151-
final MqttClient client = new MqttClient("tcp://localhost:4242", clientId, DATA_STORE);
156+
final MqttClient client = new MqttClient("tcp://localhost:" + proxy.getLocalPort(), clientId, DATA_STORE);
152157

153158
// Make sure the proxy is disabled and give it a second to close everything down
154159
proxy.disableProxy();

0 commit comments

Comments
 (0)