test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat2.java
/**
     * User2 which is currently moderator in the room for our scenario will
     * grant voice to user3 (thanks to his moderator privileges) after having
     * revoked him it in the previous test of the suite.
     *
     * We will first check that user3 has become a guest before making
     * sure that he can again send messages through the room.
     *
     * @throws OperationNotSupportedException
     * @throws OperationFailedException
     */
User2 which is currently moderator in the room for our scenario will
grant voice to user3 (thanks to his moderator privileges) after having
revoked him it in the previous test of the suite.

We will first check that user3 has become a guest before making
sure that he can again send messages through the room.


User2 which is currently moderator in the room for our scenario will grant voice to user3 ( thanks to his moderator privileges ) after having revoked him it in the previous test of the suite . We will first check that user3 has become a guest before making sure that he can again send messages through the room .
public void testGrantVoice()
    throws OperationFailedException, OperationNotSupportedException
    {
        try
        {
            Thread.sleep(2000);
        }
        catch (InterruptedException ex)
        {}
        String roomName = testRoomBaseName + roomID;
        logger.info("---= Start test for GrantVoice =--- room: " + roomName);
        ChatRoom roomUser1 = opSetMUC1.findRoom(roomName);
        assertNotNull("The room can't be retrieved on user1's side", roomUser1);
        ChatRoom roomUser2 = opSetMUC2.findRoom(roomName);
        assertNotNull("The room can't be retrieved on user2's side", roomUser2);
        MUCEventCollector roomUser1Col = new MUCEventCollector(
            roomUser1, MUCEventCollector.EVENT_ROLE);
        MUCEventCollector roomUser2Col = new MUCEventCollector(
            roomUser2, MUCEventCollector.EVENT_ROLE);
        roomUser2.grantVoice(fixture.userID3);
        roomUser1Col.waitForEvent(10000);
        roomUser2Col.waitForEvent(10000);
        assertEquals("Wrong count of collected events on user1's side",
            1, roomUser1Col.collectedEvents.size());
        ChatRoomMemberRoleChangeEvent roleEventUser1 =
            (ChatRoomMemberRoleChangeEvent) roomUser1Col.collectedEvents.get(0);
        assertEquals("Wrong count of collected events on user3's side",
            1, roomUser2Col.collectedEvents.size());
        ChatRoomMemberRoleChangeEvent roleEventUser2 =
            (ChatRoomMemberRoleChangeEvent) roomUser2Col.collectedEvents.get(0);
        assertEquals("Collected event does not belong to the right chatroom",
            roomName, XmppStringUtils.parseLocalpart(
                roleEventUser1.getSourceChatRoom().getName()));
        assertEquals("Collected event does not belong to the expected user",
            fixture.userID3,
            roleEventUser1.getSourceMember().getContactAddress());
        assertEquals("User3's previous role does not match",
            ChatRoomMemberRole.SILENT_MEMBER, roleEventUser1.getPreviousRole());
        assertEquals("Unexpected new role",
            ChatRoomMemberRole.MEMBER, roleEventUser1.getNewRole());
        assertEquals("Collected event does not belong to the right chatroom",
            roomName, XmppStringUtils.parseLocalpart(
                roleEventUser2.getSourceChatRoom().getName()));
        assertEquals("Collected event does not belong to the expected user",
            fixture.userID3,
            roleEventUser2.getSourceMember().getContactAddress());
        assertEquals("User3's previous role does not match",
            ChatRoomMemberRole.SILENT_MEMBER, roleEventUser2.getPreviousRole());
        assertEquals("Unexpected new role",
            ChatRoomMemberRole.MEMBER, roleEventUser2.getNewRole());
        logger.info("---= End test for GrantVoice =--- room: " + roomName);
    }
public void testGrantVoice ( ) throws OperationFailedException , OperationNotSupportedException { try { Thread . sleep ( 2000 ) ; } catch ( InterruptedException ex ) { } String roomName = testRoomBaseName + roomID ; logger . info ( "---= Start test for GrantVoice =--- room: " + roomName ) ; ChatRoom roomUser1 = opSetMUC1 . findRoom ( roomName ) ; assertNotNull ( "The room can't be retrieved on user1's side" , roomUser1 ) ; ChatRoom roomUser2 = opSetMUC2 . findRoom ( roomName ) ; assertNotNull ( "The room can't be retrieved on user2's side" , roomUser2 ) ; MUCEventCollector roomUser1Col = new MUCEventCollector ( roomUser1 , MUCEventCollector . EVENT_ROLE ) ; MUCEventCollector roomUser2Col = new MUCEventCollector ( roomUser2 , MUCEventCollector . EVENT_ROLE ) ; roomUser2 . grantVoice ( fixture . userID3 ) ; roomUser1Col . waitForEvent ( 10000 ) ; roomUser2Col . waitForEvent ( 10000 ) ; assertEquals ( "Wrong count of collected events on user1's side" , 1 , roomUser1Col . collectedEvents . size ( ) ) ; ChatRoomMemberRoleChangeEvent roleEventUser1 = ( ChatRoomMemberRoleChangeEvent ) roomUser1Col . collectedEvents . get ( 0 ) ; assertEquals ( "Wrong count of collected events on user3's side" , 1 , roomUser2Col . collectedEvents . size ( ) ) ; ChatRoomMemberRoleChangeEvent roleEventUser2 = ( ChatRoomMemberRoleChangeEvent ) roomUser2Col . collectedEvents . get ( 0 ) ; assertEquals ( "Collected event does not belong to the right chatroom" , roomName , XmppStringUtils . parseLocalpart ( roleEventUser1 . getSourceChatRoom ( ) . getName ( ) ) ) ; assertEquals ( "Collected event does not belong to the expected user" , fixture . userID3 , roleEventUser1 . getSourceMember ( ) . getContactAddress ( ) ) ; assertEquals ( "User3's previous role does not match" , ChatRoomMemberRole . SILENT_MEMBER , roleEventUser1 . getPreviousRole ( ) ) ; assertEquals ( "Unexpected new role" , ChatRoomMemberRole . MEMBER , roleEventUser1 . getNewRole ( ) ) ; assertEquals ( "Collected event does not belong to the right chatroom" , roomName , XmppStringUtils . parseLocalpart ( roleEventUser2 . getSourceChatRoom ( ) . getName ( ) ) ) ; assertEquals ( "Collected event does not belong to the expected user" , fixture . userID3 , roleEventUser2 . getSourceMember ( ) . getContactAddress ( ) ) ; assertEquals ( "User3's previous role does not match" , ChatRoomMemberRole . SILENT_MEMBER , roleEventUser2 . getPreviousRole ( ) ) ; assertEquals ( "Unexpected new role" , ChatRoomMemberRole . MEMBER , roleEventUser2 . getNewRole ( ) ) ; logger . info ( "---= End test for GrantVoice =--- room: " + roomName ) ; }
User2 which is currently moderator in the room for our scenario will
 grant voice to user3 (thanks to his moderator privileges) after having
 revoked him it in the previous test of the suite.
User2 which is currently moderator in the room for our scenario will grant voice to user3 ( thanks to his moderator privileges ) after having revoked him it in the previous test of the suite .
// User2 of the room grants voice right to user2: