Skip to content

Commit a710817

Browse files
committed
added some sort of unit test
1 parent 57196fc commit a710817

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

dbus-java/src/test/java/org/freedesktop/dbus/test/LowLevelTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.freedesktop.dbus.messages.DBusSignal;
1414
import org.freedesktop.dbus.messages.Message;
1515
import org.freedesktop.dbus.messages.MethodCall;
16+
import org.junit.jupiter.api.Assertions;
1617
import org.junit.jupiter.api.Test;
1718
import org.slf4j.Logger;
1819
import org.slf4j.LoggerFactory;
@@ -23,6 +24,26 @@
2324
public class LowLevelTest {
2425
private final Logger logger = LoggerFactory.getLogger(getClass());
2526

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+
2647
@Test
2748
public void testLowLevel() throws ParseException, IOException, DBusException {
2849
String addr = getAddress();

0 commit comments

Comments
 (0)