[danfossairunit] Try to make tests more stable (#9473)

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
pull/9484/head
Fabian Wolter 2020-12-22 20:31:04 +01:00 committed by GitHub
parent 4f7ac4ea30
commit 54ca612630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 10 deletions

View File

@ -17,12 +17,13 @@ import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.jupiter.api.Test;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.test.java.JavaTest;
/**
* @author Robert Bach - Initial contribution
*/
@NonNullByDefault
public class ValueCacheTest {
public class ValueCacheTest extends JavaTest {
@Test
public void updateValueNotInCache() {
@ -45,20 +46,17 @@ public class ValueCacheTest {
}
@Test
public void updateValueInCacheUnchangedButCacheDurationExpired() throws InterruptedException {
public void updateValueInCacheUnchangedButCacheDurationExpired() {
ValueCache valueCache = new ValueCache(1);
assertTrue(valueCache.updateValue("channel", OnOffType.ON));
Thread.sleep(2);
assertTrue(valueCache.updateValue("channel", OnOffType.ON));
waitForAssert(() -> assertTrue(valueCache.updateValue("channel", OnOffType.ON)));
}
@Test
public void updateValueMultipleCacheUpdatesButNotReportedAsToUpdate() throws InterruptedException {
ValueCache valueCache = new ValueCache(60);
assertTrue(valueCache.updateValue("channel", OnOffType.ON));
Thread.sleep(30);
assertFalse(valueCache.updateValue("channel", OnOffType.ON));
Thread.sleep(35);
public void updateValueMultipleCacheUpdatesButNotReportedAsToUpdate() {
ValueCache valueCache = new ValueCache(100);
assertTrue(valueCache.updateValue("channel", OnOffType.ON));
waitForAssert(() -> assertFalse(valueCache.updateValue("channel", OnOffType.ON)));
waitForAssert(() -> assertTrue(valueCache.updateValue("channel", OnOffType.ON)));
}
}