There are some integration tests that check the server functionality in complex situations in package org.freelords.network.server.integrationtest. Their basic functionality is that clients are set up to send certain commands to the server, then the server state is checked (say, clients moved to another room, then they should be in the other room).
Obviously, processing the commands takes some time that we have to wait before we can check the state. This is currently implemented as follows:
This is brittle. In particular, if the number of updates sent from the server changes, these tests need to be updated, which is rather annoying. If the number N is set incorrectly, you end up with a test that fails every now and then.
A better solution would be to pass the commands and updates around between client and server manually (to remove dependencies and uncontrollable latencies by the localhost network) and wait until the server is finished processing all commands (and the client with all updates?). This is a larger refactoring, and requires more thinking how and how intrusive it needs to be implemented.
Diff: