[smartmeter] Test fix (#13907)
Signed-off-by: Matthias Steigenberger <matthias.steigenberger@gmail.com>
This commit is contained in:
parent
7c20a4804a
commit
1a01a0e021
|
@ -18,13 +18,13 @@
|
|||
<dependency>
|
||||
<groupId>io.reactivex.rxjava2</groupId>
|
||||
<artifactId>rxjava</artifactId>
|
||||
<version>2.2.3</version>
|
||||
<version>2.2.21</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reactivestreams</groupId>
|
||||
<artifactId>reactive-streams</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -36,8 +36,14 @@
|
|||
<dependency>
|
||||
<groupId>org.openmuc</groupId>
|
||||
<artifactId>j62056</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<version>2.2.0</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.openmuc</groupId>
|
||||
<artifactId>jrxtx</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -54,7 +60,7 @@
|
|||
<phase>generate-sources</phase>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/3rdparty</source>
|
||||
<source>src/3rdparty/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -54,10 +54,10 @@ public class TestMeterReading {
|
|||
MeterDevice<Object> 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<Object> 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();
|
||||
|
|
Loading…
Reference in New Issue