industrial-data-space / idscp2-jvm

Kotlin implementation of the IDS Communication Protocol (IDSCP2) for use in JVM environments.
Apache License 2.0
5 stars 3 forks source link

Minor suggestion: Use awaitility for asynchronous testing #3

Closed oxisto closed 3 years ago

oxisto commented 3 years ago

It may be worth looking into https://github.com/awaitility/awaitility. It provides a pretty good flow for waiting or testing on things like:

while (!clientConnection.isConnected || !serverConnection.isConnected) {
   Thread.sleep(50)
}

This would be written in awaitility like

await().until(() -> clientConnection.isConnected && serverConnection.isConnected)

It also allows for fine-grained timeouts like this await().atMost(1, SECONDS).until(X) as well as specifying the polling interval.

Just a suggestions, since I have seen a lot of timing-related stuff in the test cases and this might help out there.

oxisto commented 3 years ago

Closed by https://github.com/industrial-data-space/idscp2-java/commit/64fe649dce05314e5180ad5ab0e320a58ed63929