mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Add integration test for MultiUserChat
SMACK-888 has a mention of unreachable code and is now solved
under commit 0f7b7df
.
This integration test tests those class entities which were to
be set by previously stated unreachable code.
This commit is contained in:
parent
ccbc0922ad
commit
1d49de6b60
1 changed files with 39 additions and 0 deletions
|
@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jivesoftware.smack.MessageListener;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
|
@ -39,6 +40,7 @@ import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
|||
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
||||
import org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.util.ResultSyncPoint;
|
||||
import org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
@ -120,4 +122,41 @@ public class MultiUserChatIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
mucAsSeenByOne.leave();
|
||||
mucAsSeenByTwo.leave();
|
||||
}
|
||||
|
||||
@SmackIntegrationTest
|
||||
public void mucDestroyTest() throws TimeoutException, Exception {
|
||||
|
||||
EntityBareJid mucAddress = JidCreate.entityBareFrom(Localpart.from("smack-inttest-join-leave-" + randomString),
|
||||
mucService.getDomain());
|
||||
|
||||
MultiUserChat muc = mucManagerOne.getMultiUserChat(mucAddress);
|
||||
muc.join(Resourcepart.from("nick-one"));
|
||||
|
||||
final SimpleResultSyncPoint mucDestroyed = new SimpleResultSyncPoint();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
DefaultUserStatusListener userStatusListener = new DefaultUserStatusListener() {
|
||||
@Override
|
||||
public void roomDestroyed(MultiUserChat alternateMUC, String reason) {
|
||||
mucDestroyed.signal();
|
||||
}
|
||||
};
|
||||
|
||||
muc.addUserStatusListener(userStatusListener);
|
||||
|
||||
assertTrue(mucManagerOne.getJoinedRooms().size() == 1);
|
||||
assertTrue(muc.getOccupantsCount() == 1);
|
||||
assertTrue(muc.getNickname() != null);
|
||||
|
||||
try {
|
||||
muc.destroy("Dummy reason", null);
|
||||
mucDestroyed.waitForResult(timeout);
|
||||
} finally {
|
||||
muc.removeUserStatusListener(userStatusListener);
|
||||
}
|
||||
|
||||
assertTrue(mucManagerOne.getJoinedRooms().size() == 0);
|
||||
assertTrue(muc.getOccupantsCount() == 0);
|
||||
assertTrue(muc.getNickname() == null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue