test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat2.java
/**
     * The owner of the room (the user who created it, and which is an
     * administrator too, typically user1) will grant administrator role to one
     * of our peers (user2).
     * An administrator is allowed to perform administrative functions such as
     * banning users and edit moderator list.
     *
     * @throws OperationNotSupportedException
     * @throws OperationFailedException
     */
The owner of the room (the user who created it, and which is an
administrator too, typically user1) will grant administrator role to one
of our peers (user2).
An administrator is allowed to perform administrative functions such as
banning users and edit moderator list.


The owner of the room ( the user who created it and which is an administrator too typically user1 ) will grant administrator role to one of our peers ( user2 ) . An administrator is allowed to perform administrative functions such as banning users and edit moderator list .
public void testGrantAdmin()
    throws OperationFailedException, OperationNotSupportedException
    {
        try
        {
            Thread.sleep(2000);
        }
        catch (InterruptedException ex)
        {}
        String roomName = testRoomBaseName + roomID;
        logger.info("--- Start testGrantAdmin 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 user3's side", roomUser2);
        ChatRoom roomUser3 = opSetMUC3.findRoom(roomName);
        assertNotNull("The room can't be retrieved on user3's side", roomUser3);
        MUCEventCollector roomUser1Col = new MUCEventCollector(
            roomUser1, MUCEventCollector.EVENT_ROLE);
        MUCEventCollector roomUser3Col = new MUCEventCollector(
            roomUser3, MUCEventCollector.EVENT_ROLE);
        roomUser1.grantAdmin(fixture.userID2);
        roomUser1Col.waitForEvent(10000);
        roomUser3Col.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, roomUser3Col.collectedEvents.size());
        ChatRoomMemberRoleChangeEvent roleEventUser3 =
            (ChatRoomMemberRoleChangeEvent) roomUser3Col.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.userID2,
            roleEventUser1.getSourceMember().getContactAddress());
        assertEquals("User2's previous role does not match",
            ChatRoomMemberRole.MEMBER, roleEventUser1.getPreviousRole());
        assertEquals("Unexpected new role",
            ChatRoomMemberRole.ADMINISTRATOR, roleEventUser1.getNewRole());
        assertEquals("Collected event does not belong to the right chatroom",
            roomName, XmppStringUtils.parseLocalpart(
                roleEventUser3.getSourceChatRoom().getName()));
        assertEquals("Collected event does not belong to the expected user",
            fixture.userID2,
            roleEventUser3.getSourceMember().getContactAddress());
        assertEquals("User2's previous role does not match",
            ChatRoomMemberRole.MEMBER, roleEventUser3.getPreviousRole());
        assertEquals("Unexpected new role",
            ChatRoomMemberRole.ADMINISTRATOR, roleEventUser3.getNewRole());
        logger.info("--- End testGrantAdmin room:" + roomName);
    }
public void testGrantAdmin ( ) throws OperationFailedException , OperationNotSupportedException { try { Thread . sleep ( 2000 ) ; } catch ( InterruptedException ex ) { } String roomName = testRoomBaseName + roomID ; logger . info ( "--- Start testGrantAdmin 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 user3's side" , roomUser2 ) ; ChatRoom roomUser3 = opSetMUC3 . findRoom ( roomName ) ; assertNotNull ( "The room can't be retrieved on user3's side" , roomUser3 ) ; MUCEventCollector roomUser1Col = new MUCEventCollector ( roomUser1 , MUCEventCollector . EVENT_ROLE ) ; MUCEventCollector roomUser3Col = new MUCEventCollector ( roomUser3 , MUCEventCollector . EVENT_ROLE ) ; roomUser1 . grantAdmin ( fixture . userID2 ) ; roomUser1Col . waitForEvent ( 10000 ) ; roomUser3Col . 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 , roomUser3Col . collectedEvents . size ( ) ) ; ChatRoomMemberRoleChangeEvent roleEventUser3 = ( ChatRoomMemberRoleChangeEvent ) roomUser3Col . 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 . userID2 , roleEventUser1 . getSourceMember ( ) . getContactAddress ( ) ) ; assertEquals ( "User2's previous role does not match" , ChatRoomMemberRole . MEMBER , roleEventUser1 . getPreviousRole ( ) ) ; assertEquals ( "Unexpected new role" , ChatRoomMemberRole . ADMINISTRATOR , roleEventUser1 . getNewRole ( ) ) ; assertEquals ( "Collected event does not belong to the right chatroom" , roomName , XmppStringUtils . parseLocalpart ( roleEventUser3 . getSourceChatRoom ( ) . getName ( ) ) ) ; assertEquals ( "Collected event does not belong to the expected user" , fixture . userID2 , roleEventUser3 . getSourceMember ( ) . getContactAddress ( ) ) ; assertEquals ( "User2's previous role does not match" , ChatRoomMemberRole . MEMBER , roleEventUser3 . getPreviousRole ( ) ) ; assertEquals ( "Unexpected new role" , ChatRoomMemberRole . ADMINISTRATOR , roleEventUser3 . getNewRole ( ) ) ; logger . info ( "--- End testGrantAdmin room:" + roomName ) ; }
The owner of the room (the user who created it, and which is an
 administrator too, typically user1) will grant administrator role to one
 of our peers (user2).
The owner of the room ( the user who created it and which is an administrator too typically user1 ) will grant administrator role to one of our peers ( user2 ) .
// Owner of the room grants administrator rights to user2: