use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class MultiUserChatLowLevelIntegrationTest method testMucBookmarksAutojoin.
@SmackIntegrationTest
public void testMucBookmarksAutojoin(AbstractXMPPConnection connection) throws InterruptedException, TestNotPossibleException, XMPPException, SmackException, IOException {
final BookmarkManager bookmarkManager = BookmarkManager.getBookmarkManager(connection);
if (!bookmarkManager.isSupported()) {
throw new TestNotPossibleException("Private data storage not supported");
}
final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection);
final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6));
final String randomMucName = StringUtils.randomString(6);
final DomainBareJid mucComponent = multiUserChatManager.getMucServiceDomains().get(0);
final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom(Localpart.from(randomMucName), mucComponent));
MucCreateConfigFormHandle handle = muc.createOrJoin(mucNickname);
if (handle != null) {
handle.makeInstant();
}
muc.leave();
bookmarkManager.addBookmarkedConference("Smack Inttest: " + testRunId, muc.getRoom(), true, mucNickname, null);
connection.disconnect();
connection.connect().login();
// MucBookmarkAutojoinManager is also able to do its task automatically
// after every login, it's not deterministic when this will be finished.
// So we trigger it manually here.
MucBookmarkAutojoinManager.getInstanceFor(connection).autojoinBookmarkedConferences();
assertTrue(muc.isJoined());
// If the test went well, leave the MUC
muc.leave();
}
use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class MultiUserChatRolesAffiliationsPrivilegesIntegrationTest method mucTestDefaultRoleForAffiliationInUnmoderatedRoom.
/**
* Asserts that an unmoderated 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 mucTestDefaultRoleForAffiliationInUnmoderatedRoom() throws Exception {
EntityBareJid mucAddress = getRandomRoom("smack-inttest-unmoderatedroles");
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);
createMuc(mucAsSeenByOne, nicknameOne);
try {
mucAsSeenByTwo.join(nicknameTwo);
mucAsSeenByThree.join(nicknameThree);
final ResultSyncPoint<String, Exception> resultSyncPoint = new ResultSyncPoint<>();
mucAsSeenByOne.addParticipantStatusListener(new ParticipantStatusListener() {
@Override
public void adminGranted(EntityFullJid participant) {
resultSyncPoint.signal("done");
}
});
mucAsSeenByOne.grantAdmin(conTwo.getUser().asBareJid());
resultSyncPoint.waitForResult(timeout);
assertEquals(mucAsSeenByOne.getOccupantsCount(), 3);
assertEquals(MUCRole.moderator, mucAsSeenByOne.getOccupant(JidCreate.entityFullFrom(mucAddress, nicknameOne)).getRole());
assertEquals(MUCRole.moderator, mucAsSeenByOne.getOccupant(JidCreate.entityFullFrom(mucAddress, nicknameTwo)).getRole());
assertEquals(MUCRole.participant, mucAsSeenByOne.getOccupant(JidCreate.entityFullFrom(mucAddress, nicknameThree)).getRole());
} finally {
tryDestroy(mucAsSeenByOne);
}
}
use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class MultiUserChatRolesAffiliationsPrivilegesIntegrationTest method mucAffiliationTestForRemovingAdmin.
/**
* Asserts that a user who undergoes an affiliation change receives that change as a presence update
*
* <p>From XEP-0045 § 5.2.2:</p>
* <blockquote>
* ...a MUC service implementation MUST change the user's affiliation to reflect the change and communicate that to
* all occupants...
* </blockquote>
*
* <p>From XEP-0045 § 10.7:</p>
* <blockquote>
* If the user is in the room, the service MUST then send updated presence from this individual to all occupants,
* indicating the loss of admin status by sending a presence element...
* </blockquote>
*
* @throws Exception when errors occur
*/
@SmackIntegrationTest
public void mucAffiliationTestForRemovingAdmin() 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 adminRevoked() {
resultSyncPoint.signal("done");
}
});
createMuc(mucAsSeenByOne, "one-" + randomString);
try {
final Resourcepart nicknameTwo = Resourcepart.from("two-" + randomString);
mucAsSeenByTwo.join(nicknameTwo);
mucAsSeenByOne.grantAdmin(conTwo.getUser().asBareJid());
mucAsSeenByOne.revokeAdmin(conTwo.getUser().asEntityBareJid());
resultSyncPoint.waitForResult(timeout);
} finally {
tryDestroy(mucAsSeenByOne);
}
}
use of org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest in project Smack by igniterealtime.
the class MultiUserChatRolesAffiliationsPrivilegesIntegrationTest method mucRoleTestForWitnessingModerator.
/**
* 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 § 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 mucRoleTestForWitnessingModerator() 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 moderatorGranted(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.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 mucRoleTestForWitnessingModeratorRemoval.
/**
* 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 § 9.7:</p>
* <blockquote>
* The service MUST then send updated presence from this individual to all occupants, indicating the removal of
* moderator status...
* </blockquote>
*
* @throws Exception when errors occur
*/
@SmackIntegrationTest
public void mucRoleTestForWitnessingModeratorRemoval() 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 moderatorRevoked(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.grantModerator(nicknameTwo);
mucAsSeenByOne.revokeModerator(nicknameTwo);
resultSyncPoint.waitForResult(timeout);
} finally {
tryDestroy(mucAsSeenByOne);
}
}
Aggregations