use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class MultiUserChatRolesAffiliationsPrivilegesIntegrationTest method mucTestDefaultRoleForAffiliationInMembersOnlyRoom.
/**
* Asserts that a members-only room assigns the correct default roles for a given affiliation
*
* <p>From XEP-0045 § 5.1.2:</p>
* <blockquote>
* ...the initial default roles that a service SHOULD set based on the user's affiliation...
* </blockquote>
*
* @throws Exception when errors occur
*/
@SmackIntegrationTest
public void mucTestDefaultRoleForAffiliationInMembersOnlyRoom() throws Exception {
EntityBareJid mucAddress = getRandomRoom("smack-inttest-membersonlyroles");
MultiUserChat mucAsSeenByOne = mucManagerOne.getMultiUserChat(mucAddress);
MultiUserChat mucAsSeenByTwo = mucManagerTwo.getMultiUserChat(mucAddress);
MultiUserChat mucAsSeenByThree = mucManagerThree.getMultiUserChat(mucAddress);
final Resourcepart nicknameOne = Resourcepart.from("one-" + randomString);
final Resourcepart nicknameTwo = Resourcepart.from("two-" + randomString);
final Resourcepart nicknameThree = Resourcepart.from("three-" + randomString);
final EntityFullJid jidOne = JidCreate.entityFullFrom(mucAddress, nicknameOne);
final EntityFullJid jidTwo = JidCreate.entityFullFrom(mucAddress, nicknameTwo);
final EntityFullJid jidThree = JidCreate.entityFullFrom(mucAddress, nicknameThree);
createMembersOnlyMuc(mucAsSeenByOne, nicknameOne);
final ResultSyncPoint<String, Exception> adminResultSyncPoint = new ResultSyncPoint<>();
mucAsSeenByOne.addParticipantStatusListener(new ParticipantStatusListener() {
@Override
public void adminGranted(EntityFullJid participant) {
adminResultSyncPoint.signal("done");
}
});
try {
mucAsSeenByOne.grantMembership(conTwo.getUser().asBareJid());
mucAsSeenByOne.grantMembership(conThree.getUser().asBareJid());
mucAsSeenByTwo.join(nicknameTwo);
mucAsSeenByThree.join(nicknameThree);
mucAsSeenByOne.grantAdmin(conTwo.getUser().asBareJid());
adminResultSyncPoint.waitForResult(timeout);
assertEquals(mucAsSeenByOne.getOccupantsCount(), 3);
assertEquals(MUCRole.moderator, mucAsSeenByOne.getOccupant(jidOne).getRole());
assertEquals(MUCRole.moderator, mucAsSeenByOne.getOccupant(jidTwo).getRole());
assertEquals(MUCRole.participant, mucAsSeenByOne.getOccupant(jidThree).getRole());
} finally {
tryDestroy(mucAsSeenByOne);
}
}
use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class MultiUserChatRolesAffiliationsPrivilegesIntegrationTest method mucRoleTestForWitnessingRevokingVoice.
/**
* Asserts that a user who is present when another user undergoes a role change receives that change as a presence update
*
* <p>From XEP-0045 § 5.1.3:</p>
* <blockquote>
* ...a MUC service implementation MUST change the occupant's role to reflect the change and communicate the change
* to all occupants...
* </blockquote>
*
* <p>From XEP-0045 § 8.4:</p>
* <blockquote>
* The service MUST then send updated presence from this individual to all occupants, indicating the removal of
* voice privileges...
* </blockquote>
*
* @throws Exception when errors occur
*/
@SmackIntegrationTest
public void mucRoleTestForWitnessingRevokingVoice() throws Exception {
EntityBareJid mucAddress = getRandomRoom("smack-inttest");
MultiUserChat mucAsSeenByOne = mucManagerOne.getMultiUserChat(mucAddress);
MultiUserChat mucAsSeenByTwo = mucManagerTwo.getMultiUserChat(mucAddress);
MultiUserChat mucAsSeenByThree = mucManagerThree.getMultiUserChat(mucAddress);
final ResultSyncPoint<String, Exception> resultSyncPoint = new ResultSyncPoint<>();
mucAsSeenByThree.addParticipantStatusListener(new ParticipantStatusListener() {
@Override
public void voiceRevoked(EntityFullJid participant) {
resultSyncPoint.signal("done");
}
});
createMuc(mucAsSeenByOne, "one-" + randomString);
try {
final Resourcepart nicknameTwo = Resourcepart.from("two-" + randomString);
final Resourcepart nicknameThree = Resourcepart.from("three-" + randomString);
mucAsSeenByTwo.join(nicknameTwo);
mucAsSeenByThree.join(nicknameThree);
mucAsSeenByOne.revokeVoice(nicknameTwo);
resultSyncPoint.waitForResult(timeout);
} finally {
tryDestroy(mucAsSeenByOne);
}
}
use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class MultiUserChatRolesAffiliationsPrivilegesIntegrationTest method mucRoleTestForReceivingModerator.
/**
* Asserts that a user who undergoes a role change receives that change as a presence update
*
* <p>From XEP-0045 § 5.1.3:</p>
* <blockquote>
* ...a MUC service implementation MUST change the occupant's role to reflect the change and communicate the change
* to all occupants...
* </blockquote>
*
* <p>From XEP-0045 § 9.6:</p>
* <blockquote>
* The service MUST then send updated presence from this individual to all occupants, indicating the addition of
* moderator status...
* </blockquote>
*
* @throws Exception when errors occur
*/
@SmackIntegrationTest
public void mucRoleTestForReceivingModerator() throws Exception {
EntityBareJid mucAddress = getRandomRoom("smack-inttest");
MultiUserChat mucAsSeenByOne = mucManagerOne.getMultiUserChat(mucAddress);
MultiUserChat mucAsSeenByTwo = mucManagerTwo.getMultiUserChat(mucAddress);
final ResultSyncPoint<String, Exception> resultSyncPoint = new ResultSyncPoint<>();
mucAsSeenByTwo.addUserStatusListener(new UserStatusListener() {
@Override
public void moderatorGranted() {
resultSyncPoint.signal("done");
}
});
createMuc(mucAsSeenByOne, "one-" + randomString);
try {
final Resourcepart nicknameTwo = Resourcepart.from("two-" + randomString);
mucAsSeenByTwo.join(nicknameTwo);
// This implicitly tests "The service MUST add the user to the moderator list and then inform the admin of
// success" in §9.6, since it'll throw on either an error IQ or on no response.
mucAsSeenByOne.grantModerator(nicknameTwo);
resultSyncPoint.waitForResult(timeout);
} finally {
tryDestroy(mucAsSeenByOne);
}
}
use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class MultiUserChatRolesAffiliationsPrivilegesIntegrationTest method mucRoleTestForRevokingVoice.
/**
* Asserts that a user in an unmoderated room who undergoes an afilliation change receives that change as a presence update
*
* <p>From XEP-0045 § 5.1.3:</p>
* <blockquote>
* ...a MUC service implementation MUST change the occupant's role to reflect the change and communicate the change
* to all occupants...
* </blockquote>
*
* <p>From XEP-0045 § 8.4:</p>
* <blockquote>
* The service MUST then send updated presence from this individual to all occupants, indicating the removal of
* voice privileges...
* </blockquote>
*
* @throws Exception when errors occur
*/
@SmackIntegrationTest
public void mucRoleTestForRevokingVoice() throws Exception {
EntityBareJid mucAddress = getRandomRoom("smack-inttest");
MultiUserChat mucAsSeenByOne = mucManagerOne.getMultiUserChat(mucAddress);
MultiUserChat mucAsSeenByTwo = mucManagerTwo.getMultiUserChat(mucAddress);
final ResultSyncPoint<String, Exception> resultSyncPoint = new ResultSyncPoint<>();
mucAsSeenByTwo.addUserStatusListener(new UserStatusListener() {
@Override
public void voiceRevoked() {
resultSyncPoint.signal("done");
}
});
createMuc(mucAsSeenByOne, "one-" + randomString);
try {
final Resourcepart nicknameTwo = Resourcepart.from("two-" + randomString);
mucAsSeenByTwo.join(nicknameTwo);
mucAsSeenByOne.revokeVoice(nicknameTwo);
resultSyncPoint.waitForResult(timeout);
} finally {
tryDestroy(mucAsSeenByOne);
}
}
use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class LowLevelRosterIntegrationTest method testPresenceEventListenersOffline.
@SmackIntegrationTest
public void testPresenceEventListenersOffline(final AbstractXMPPConnection conOne, final AbstractXMPPConnection conTwo) throws TimeoutException, Exception {
IntegrationTestRosterUtil.ensureBothAccountsAreNotInEachOthersRoster(conOne, conTwo);
final Roster rosterOne = Roster.getInstanceFor(conOne);
final Roster rosterTwo = Roster.getInstanceFor(conTwo);
rosterOne.createItem(conTwo.getUser().asBareJid(), "Con Two", null);
rosterTwo.createItem(conOne.getUser().asBareJid(), "Con One", null);
IntegrationTestRosterUtil.ensureBothAccountsAreSubscribedToEachOther(conOne, conTwo, timeout);
final SimpleResultSyncPoint offlineTriggered = new SimpleResultSyncPoint();
rosterOne.addPresenceEventListener(new AbstractPresenceEventListener() {
@Override
public void presenceUnavailable(FullJid jid, Presence presence) {
if (!jid.equals(conTwo.getUser())) {
return;
}
offlineTriggered.signal();
}
});
// Disconnect conTwo, this should cause an 'unavailable' presence to be send from conTwo to
// conOne.
conTwo.disconnect();
Boolean result = offlineTriggered.waitForResult(timeout);
if (!result) {
throw new Exception("presenceUnavailable() was not called");
}
}
Aggregations