mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
[sinttest] Improve mucChangeNicknameInformationTest()
Only declare the body of the participant listeners once. And increase the try block, to account, for example, for participantOneSeesTwoEnter.waitForResult() throwing.
This commit is contained in:
parent
2a243fe3b6
commit
9f58c992bd
1 changed files with 27 additions and 30 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015-2020 Florian Schmaus, 2021 Dan Caseley
|
||||
* Copyright 2015-2024 Florian Schmaus, 2021 Dan Caseley
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -30,6 +30,7 @@ import java.util.Set;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jivesoftware.smack.PresenceListener;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -968,6 +969,7 @@ public class MultiUserChatOccupantIntegrationTest extends AbstractMultiUserChatI
|
|||
|
||||
createMuc(mucAsSeenByOne, nicknameOne);
|
||||
|
||||
try {
|
||||
SimpleResultSyncPoint participantOneSeesTwoEnter = new SimpleResultSyncPoint();
|
||||
mucAsSeenByOne.addParticipantListener(presence -> {
|
||||
if (nicknameTwoOriginal.equals(presence.getFrom().getResourceOrEmpty())) {
|
||||
|
@ -984,20 +986,15 @@ public class MultiUserChatOccupantIntegrationTest extends AbstractMultiUserChatI
|
|||
// reversed. Here we will expect an unavailable and an available presence stanza sent to both participant one
|
||||
// and participant two. So that adds up to a total of four.
|
||||
MultiResultSyncPoint<Presence, ?> participantTwoPresencesSyncPoint = new MultiResultSyncPoint<>(4);
|
||||
mucAsSeenByOne.addParticipantListener(presence -> {
|
||||
if (nicknameTwoOriginal.equals(presence.getFrom().getResourceOrEmpty()) || nicknameTwoNew.equals(
|
||||
presence.getFrom().getResourceOrEmpty())) {
|
||||
PresenceListener mucPresenceListener = presence -> {
|
||||
Resourcepart fromResource = presence.getFrom().getResourceOrEmpty();
|
||||
if (nicknameTwoOriginal.equals(fromResource) || nicknameTwoNew.equals(fromResource)) {
|
||||
participantTwoPresencesSyncPoint.signal(presence);
|
||||
}
|
||||
});
|
||||
mucAsSeenByTwo.addParticipantListener(presence -> {
|
||||
if (nicknameTwoOriginal.equals(presence.getFrom().getResourceOrEmpty()) || nicknameTwoNew.equals(
|
||||
presence.getFrom().getResourceOrEmpty())) {
|
||||
participantTwoPresencesSyncPoint.signal(presence);
|
||||
}
|
||||
});
|
||||
};
|
||||
mucAsSeenByOne.addParticipantListener(mucPresenceListener);
|
||||
mucAsSeenByTwo.addParticipantListener(mucPresenceListener);
|
||||
|
||||
try {
|
||||
// Participant two changes nickname
|
||||
mucAsSeenByTwo.changeNickname(nicknameTwoNew);
|
||||
final List<Presence> partTwoPresencesReceived = participantTwoPresencesSyncPoint.waitForResults(
|
||||
|
|
Loading…
Reference in a new issue