|
13 | 13 | import org.freedesktop.dbus.messages.DBusSignal; |
14 | 14 | import org.freedesktop.dbus.messages.Message; |
15 | 15 | import org.freedesktop.dbus.messages.MethodCall; |
| 16 | +import org.junit.jupiter.api.Assertions; |
16 | 17 | import org.junit.jupiter.api.Test; |
17 | 18 | import org.slf4j.Logger; |
18 | 19 | import org.slf4j.LoggerFactory; |
|
23 | 24 | public class LowLevelTest { |
24 | 25 | private final Logger logger = LoggerFactory.getLogger(getClass()); |
25 | 26 |
|
| 27 | + @Test |
| 28 | + public void testTimeout() throws ParseException, IOException, DBusException { |
| 29 | + String addr = getAddress(); |
| 30 | + logger.debug(addr); |
| 31 | + BusAddress address = new BusAddress(addr); |
| 32 | + logger.debug(address + ""); |
| 33 | + int timeout = 100; |
| 34 | + try (AbstractTransport conn = TransportFactory.createTransport(address, timeout)) { |
| 35 | + long before = System.currentTimeMillis(); |
| 36 | + conn.readMessage(); |
| 37 | + long after = System.currentTimeMillis(); |
| 38 | + long timeOutMeasured = after - before; |
| 39 | + Assertions.assertTrue(timeOutMeasured >= timeout, "To early unblocked"); |
| 40 | + //There is no strict limit on this however the 2 times is a safe limit |
| 41 | + Assertions.assertTrue(timeOutMeasured < timeout * 2, "Blocking to long"); |
| 42 | + System.out.println(timeOutMeasured); |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + |
26 | 47 | @Test |
27 | 48 | public void testLowLevel() throws ParseException, IOException, DBusException { |
28 | 49 | String addr = getAddress(); |
|
0 commit comments