diff --git a/bundles/org.openhab.binding.smartmeter/pom.xml b/bundles/org.openhab.binding.smartmeter/pom.xml index b2e6537a9..54131d553 100644 --- a/bundles/org.openhab.binding.smartmeter/pom.xml +++ b/bundles/org.openhab.binding.smartmeter/pom.xml @@ -18,13 +18,13 @@ io.reactivex.rxjava2 rxjava - 2.2.3 + 2.2.21 compile org.reactivestreams reactive-streams - 1.0.2 + 1.0.4 compile @@ -36,8 +36,14 @@ org.openmuc j62056 - 2.1.0 + 2.2.0 compile + + + org.openmuc + jrxtx + + @@ -54,7 +60,7 @@ generate-sources - src/3rdparty + src/3rdparty/java diff --git a/bundles/org.openhab.binding.smartmeter/src/test/java/org/openhab/binding/smartmeter/TestMeterReading.java b/bundles/org.openhab.binding.smartmeter/src/test/java/org/openhab/binding/smartmeter/TestMeterReading.java index 32ea25ca4..c80acdc8f 100644 --- a/bundles/org.openhab.binding.smartmeter/src/test/java/org/openhab/binding/smartmeter/TestMeterReading.java +++ b/bundles/org.openhab.binding.smartmeter/src/test/java/org/openhab/binding/smartmeter/TestMeterReading.java @@ -54,10 +54,10 @@ public class TestMeterReading { MeterDevice meter = getMeterDevice(connector); MeterValueListener changeListener = Mockito.mock(MeterValueListener.class); meter.addValueChangeListener(changeListener); - Disposable disposable = meter.readValues(5000, Executors.newScheduledThreadPool(1), period); + long executionTime = period.toMillis() * executionCount; + Disposable disposable = meter.readValues(executionTime, Executors.newScheduledThreadPool(1), period); try { - verify(changeListener, after(executionCount * period.toMillis() + period.toMillis() / 2).never()) - .errorOccurred(any()); + verify(changeListener, after(executionTime + period.toMillis() / 2 + 50).never()).errorOccurred(any()); verify(changeListener, times(executionCount)).valueChanged(any()); } finally { disposable.dispose(); @@ -90,7 +90,7 @@ public class TestMeterReading { final int timeout = 5000; MockMeterReaderConnector connector = spy(getMockedConnector(true, () -> { try { - Thread.sleep(timeout + 2000); + Thread.sleep(timeout); } catch (InterruptedException e) { } return new Object(); @@ -98,9 +98,9 @@ public class TestMeterReading { MeterDevice meter = getMeterDevice(connector); MeterValueListener changeListener = Mockito.mock(MeterValueListener.class); meter.addValueChangeListener(changeListener); - Disposable disposable = meter.readValues(5000, Executors.newScheduledThreadPool(2), period); + Disposable disposable = meter.readValues(timeout / 2, Executors.newScheduledThreadPool(2), period); try { - verify(changeListener, after(timeout + 3000).times(1)).errorOccurred(any(TimeoutException.class)); + verify(changeListener, timeout(timeout)).errorOccurred(any(TimeoutException.class)); } finally { disposable.dispose(); } @@ -112,7 +112,7 @@ public class TestMeterReading { final int timeout = 5000; MockMeterReaderConnector connector = spy(getMockedConnector(true, () -> { try { - Thread.sleep(timeout + 2000); + Thread.sleep(timeout); } catch (InterruptedException e) { } throw new RuntimeException(new IOException("fucked up")); @@ -122,9 +122,9 @@ public class TestMeterReading { RxJavaPlugins.setErrorHandler(errorHandler); MeterValueListener changeListener = Mockito.mock(MeterValueListener.class); meter.addValueChangeListener(changeListener); - Disposable disposable = meter.readValues(5000, Executors.newScheduledThreadPool(2), period); + Disposable disposable = meter.readValues(timeout / 2, Executors.newScheduledThreadPool(2), period); try { - verify(changeListener, after(timeout + 3000).times(1)).errorOccurred(any(TimeoutException.class)); + verify(changeListener, timeout(timeout)).errorOccurred(any(TimeoutException.class)); verifyNoMoreInteractions(errorHandler); } finally { disposable.dispose();