mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +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);
|
final Resourcepart nicknameThree = Resourcepart.from("three-" + randomString);
|
||||||
|
|
||||||
createMuc(mucAsSeenByOne, nicknameOne);
|
createMuc(mucAsSeenByOne, nicknameOne);
|
||||||
mucAsSeenByTwo.join(nicknameTwo);
|
|
||||||
|
|
||||||
SimpleResultSyncPoint oneSeesTwo = new SimpleResultSyncPoint();
|
SimpleResultSyncPoint oneSeesTwo = new SimpleResultSyncPoint();
|
||||||
mucAsSeenByOne.addParticipantListener(presence -> {
|
mucAsSeenByOne.addParticipantListener(presence -> {
|
||||||
if (nicknameTwo.equals(presence.getFrom().getResourceOrEmpty())) {
|
if (nicknameTwo.equals(presence.getFrom().getResourceOrEmpty())) {
|
||||||
oneSeesTwo.signal();
|
oneSeesTwo.signal();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mucAsSeenByOne.grantModerator(nicknameTwo);
|
mucAsSeenByTwo.join(nicknameTwo);
|
||||||
oneSeesTwo.waitForResult(timeout);
|
oneSeesTwo.waitForResult(timeout);
|
||||||
|
mucAsSeenByOne.grantModerator(nicknameTwo);
|
||||||
|
|
||||||
List<Presence> results = new ArrayList<>();
|
List<Presence> results = new ArrayList<>();
|
||||||
mucAsSeenByThree.addParticipantListener(results::add);
|
mucAsSeenByThree.addParticipantListener(results::add);
|
||||||
|
|
Loading…
Reference in a new issue