[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>
|
<dependency>
|
||||||
<groupId>io.reactivex.rxjava2</groupId>
|
<groupId>io.reactivex.rxjava2</groupId>
|
||||||
<artifactId>rxjava</artifactId>
|
<artifactId>rxjava</artifactId>
|
||||||
<version>2.2.3</version>
|
<version>2.2.21</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.reactivestreams</groupId>
|
<groupId>org.reactivestreams</groupId>
|
||||||
<artifactId>reactive-streams</artifactId>
|
<artifactId>reactive-streams</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.4</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -36,8 +36,14 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openmuc</groupId>
|
<groupId>org.openmuc</groupId>
|
||||||
<artifactId>j62056</artifactId>
|
<artifactId>j62056</artifactId>
|
||||||
<version>2.1.0</version>
|
<version>2.2.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.openmuc</groupId>
|
||||||
|
<artifactId>jrxtx</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -54,7 +60,7 @@
|
||||||
<phase>generate-sources</phase>
|
<phase>generate-sources</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sources>
|
<sources>
|
||||||
<source>src/3rdparty</source>
|
<source>src/3rdparty/java</source>
|
||||||
</sources>
|
</sources>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -54,10 +54,10 @@ public class TestMeterReading {
|
||||||
MeterDevice<Object> meter = getMeterDevice(connector);
|
MeterDevice<Object> meter = getMeterDevice(connector);
|
||||||
MeterValueListener changeListener = Mockito.mock(MeterValueListener.class);
|
MeterValueListener changeListener = Mockito.mock(MeterValueListener.class);
|
||||||
meter.addValueChangeListener(changeListener);
|
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 {
|
try {
|
||||||
verify(changeListener, after(executionCount * period.toMillis() + period.toMillis() / 2).never())
|
verify(changeListener, after(executionTime + period.toMillis() / 2 + 50).never()).errorOccurred(any());
|
||||||
.errorOccurred(any());
|
|
||||||
verify(changeListener, times(executionCount)).valueChanged(any());
|
verify(changeListener, times(executionCount)).valueChanged(any());
|
||||||
} finally {
|
} finally {
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
|
@ -90,7 +90,7 @@ public class TestMeterReading {
|
||||||
final int timeout = 5000;
|
final int timeout = 5000;
|
||||||
MockMeterReaderConnector connector = spy(getMockedConnector(true, () -> {
|
MockMeterReaderConnector connector = spy(getMockedConnector(true, () -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(timeout + 2000);
|
Thread.sleep(timeout);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
return new Object();
|
return new Object();
|
||||||
|
@ -98,9 +98,9 @@ public class TestMeterReading {
|
||||||
MeterDevice<Object> meter = getMeterDevice(connector);
|
MeterDevice<Object> meter = getMeterDevice(connector);
|
||||||
MeterValueListener changeListener = Mockito.mock(MeterValueListener.class);
|
MeterValueListener changeListener = Mockito.mock(MeterValueListener.class);
|
||||||
meter.addValueChangeListener(changeListener);
|
meter.addValueChangeListener(changeListener);
|
||||||
Disposable disposable = meter.readValues(5000, Executors.newScheduledThreadPool(2), period);
|
Disposable disposable = meter.readValues(timeout / 2, Executors.newScheduledThreadPool(2), period);
|
||||||
try {
|
try {
|
||||||
verify(changeListener, after(timeout + 3000).times(1)).errorOccurred(any(TimeoutException.class));
|
verify(changeListener, timeout(timeout)).errorOccurred(any(TimeoutException.class));
|
||||||
} finally {
|
} finally {
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public class TestMeterReading {
|
||||||
final int timeout = 5000;
|
final int timeout = 5000;
|
||||||
MockMeterReaderConnector connector = spy(getMockedConnector(true, () -> {
|
MockMeterReaderConnector connector = spy(getMockedConnector(true, () -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(timeout + 2000);
|
Thread.sleep(timeout);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
throw new RuntimeException(new IOException("fucked up"));
|
throw new RuntimeException(new IOException("fucked up"));
|
||||||
|
@ -122,9 +122,9 @@ public class TestMeterReading {
|
||||||
RxJavaPlugins.setErrorHandler(errorHandler);
|
RxJavaPlugins.setErrorHandler(errorHandler);
|
||||||
MeterValueListener changeListener = Mockito.mock(MeterValueListener.class);
|
MeterValueListener changeListener = Mockito.mock(MeterValueListener.class);
|
||||||
meter.addValueChangeListener(changeListener);
|
meter.addValueChangeListener(changeListener);
|
||||||
Disposable disposable = meter.readValues(5000, Executors.newScheduledThreadPool(2), period);
|
Disposable disposable = meter.readValues(timeout / 2, Executors.newScheduledThreadPool(2), period);
|
||||||
try {
|
try {
|
||||||
verify(changeListener, after(timeout + 3000).times(1)).errorOccurred(any(TimeoutException.class));
|
verify(changeListener, timeout(timeout)).errorOccurred(any(TimeoutException.class));
|
||||||
verifyNoMoreInteractions(errorHandler);
|
verifyNoMoreInteractions(errorHandler);
|
||||||
} finally {
|
} finally {
|
||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
|
|
Loading…
Reference in New Issue