Fix unstable MqttBrokerConnectionTests (#1191)
Using waitForAssert instead of sleeping 10ms makes the tests stable when the system has some load. Fixes #1139 Signed-off-by: Wouter Born <github@maindrain.net>pull/1193/head
parent
b006232cc0
commit
cd3f33738f
|
@ -18,6 +18,12 @@
|
|||
<artifactId>org.openhab.core.config.core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openhab.core.bundles</groupId>
|
||||
<artifactId>org.openhab.core.test</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||
import org.eclipse.smarthome.io.transport.mqtt.internal.client.MqttAsyncClientWrapper;
|
||||
import org.eclipse.smarthome.io.transport.mqtt.reconnect.AbstractReconnectStrategy;
|
||||
import org.eclipse.smarthome.io.transport.mqtt.reconnect.PeriodicReconnectStrategy;
|
||||
import org.eclipse.smarthome.test.java.JavaTest;
|
||||
import org.junit.Test;
|
||||
import org.osgi.service.cm.ConfigurationException;
|
||||
|
||||
|
@ -43,7 +44,7 @@ import com.hivemq.client.mqtt.mqtt3.message.publish.Mqtt3Publish;
|
|||
* @author David Graeff - Initial contribution
|
||||
* @author Jan N. Klug - adjusted to HiveMQ client
|
||||
*/
|
||||
public class MqttBrokerConnectionTests {
|
||||
public class MqttBrokerConnectionTests extends JavaTest {
|
||||
@Test
|
||||
public void subscribeBeforeOnlineThenConnect()
|
||||
throws ConfigurationException, MqttException, InterruptedException, ExecutionException, TimeoutException {
|
||||
|
@ -168,8 +169,7 @@ public class MqttBrokerConnectionTests {
|
|||
|
||||
// Check lostConnect
|
||||
verify(mockPolicy).lostConnection();
|
||||
Thread.sleep(10);
|
||||
verify(connection).start();
|
||||
waitForAssert(() -> verify(connection).start());
|
||||
assertTrue(mockPolicy.isReconnecting());
|
||||
|
||||
// Fake connection established
|
||||
|
|
Loading…
Reference in New Issue