mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
[sinttest] Fix race condition in MUC test
When occupant One waits for occupant Two to join the room, One should register the corresponding listener _before_ Two joins. Without this, a race conditions occurs, where Two could have joined the room before One registered the listener, thus missing the event.
This commit is contained in:
parent
4f09244253
commit
adafcdb6d1
1 changed files with 2 additions and 3 deletions
|
@ -214,16 +214,15 @@ public class MultiUserChatOccupantIntegrationTest extends AbstractMultiUserChatI
|
|||
final Resourcepart nicknameThree = Resourcepart.from("three-" + randomString);
|
||||
|
||||
createMuc(mucAsSeenByOne, nicknameOne);
|
||||
mucAsSeenByTwo.join(nicknameTwo);
|
||||
|
||||
SimpleResultSyncPoint oneSeesTwo = new SimpleResultSyncPoint();
|
||||
mucAsSeenByOne.addParticipantListener(presence -> {
|
||||
if (nicknameTwo.equals(presence.getFrom().getResourceOrEmpty())) {
|
||||
oneSeesTwo.signal();
|
||||
}
|
||||
});
|
||||
mucAsSeenByOne.grantModerator(nicknameTwo);
|
||||
mucAsSeenByTwo.join(nicknameTwo);
|
||||
oneSeesTwo.waitForResult(timeout);
|
||||
mucAsSeenByOne.grantModerator(nicknameTwo);
|
||||
|
||||
List<Presence> results = new ArrayList<>();
|
||||
mucAsSeenByThree.addParticipantListener(results::add);
|
||||
|
|
Loading…
Reference in a new issue