[danfossairunit] Try to make tests more stable (#9473)
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>pull/9484/head
parent
4f7ac4ea30
commit
54ca612630
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue