use of org.openmuc.jrxtx.SerialPortTimeoutException in project OpenMUC by isc-konstanz.
the class DriverTest method testScanMBusSapReadThrowsIOException.
@Test(expected = ScanException.class)
public void testScanMBusSapReadThrowsIOException() throws Exception {
MBusConnection con = mockNewBuilderCon();
when(con.read(1)).thenReturn(new VariableDataStructure(null, 0, 0, null, null));
when(con.read(250)).thenThrow(new SerialPortTimeoutException());
when(con.read(anyInt())).thenThrow(new IOException());
final Driver mdriver = new Driver();
class InterruptScanThread implements Runnable {
@Override
public void run() {
try {
Thread.sleep(100);
mdriver.interruptDeviceScan();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
new InterruptScanThread().run();
mdriver.scanForDevices("/dev/ttyS100:2400", mock(DriverDeviceScanListener.class));
}
Aggregations