Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {

async.await();

// the connection should be dropped within a 1 second window after the expected keep alive timeout
long elapsed = ended - started;
// consider a range of 500 ms
context.assertTrue(elapsed > (timeout * 1000 - 500) && elapsed < (timeout * 1000 + 500),
elapsed + " > " + ((timeout * 1000 - 500)) + " && " + elapsed + " < " + (timeout * 1000 + 500) + " != true");
long expectedMin = timeout * 1000L;
long expectedMax = expectedMin + 1000L;
context.assertTrue(elapsed >= expectedMin && elapsed <= expectedMax,
String.format("elapsed %d ms is not in the expected range [%d, %d] ms", elapsed, expectedMin, expectedMax));

} catch (MqttException e) {
context.fail(e);
Expand Down