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 ownership privileges to
     * one of our peers (user2).
     * An owner is allowed to change defining room features as well as perform
     * all administrative functions.
     *
     * @throws OperationNotSupportedException
     * @throws OperationFailedException
     */
The owner of the room (the user who created it, and which is an
administrator too, typically user1) will grant ownership privileges to
one of our peers (user2).
An owner is allowed to change defining room features as well as perform
all administrative functions.


The owner of the room ( the user who created it and which is an administrator too typically user1 ) will grant ownership privileges to one of our peers ( user2 ) . An owner is allowed to change defining room features as well as perform all administrative functions .
public void testGrantOwnership()
    throws OperationFailedException, OperationNotSupportedException
    {
        try
        {
            Thread.sleep(2000);
        }
        catch (InterruptedException ex)
        {}
        String roomName = testRoomBaseName + roomID;
        logger.info("--- Start testGrantOwnership room:" + roomName);
        ChatRoom roomUser1 = opSetMUC1.findRoom(roomName);
        assertNotNull("The room can't be retrieved on user1's side", roomUser1);
        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.grantOwnership(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.ADMINISTRATOR, roleEventUser1.getPreviousRole());
        assertEquals("Unexpected new role",
            ChatRoomMemberRole.OWNER, 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.ADMINISTRATOR, roleEventUser3.getPreviousRole());
        assertEquals("Unexpected new role",
            ChatRoomMemberRole.OWNER, roleEventUser3.getNewRole());
        logger.info("--- End testGrantOwnership room:" + roomName);
    }
public void testGrantOwnership ( ) throws OperationFailedException , OperationNotSupportedException { try { Thread . sleep ( 2000 ) ; } catch ( InterruptedException ex ) { } String roomName = testRoomBaseName + roomID ; logger . info ( "--- Start testGrantOwnership room:" + roomName ) ; ChatRoom roomUser1 = opSetMUC1 . findRoom ( roomName ) ; assertNotNull ( "The room can't be retrieved on user1's side" , roomUser1 ) ; 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 . grantOwnership ( 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 . ADMINISTRATOR , roleEventUser1 . getPreviousRole ( ) ) ; assertEquals ( "Unexpected new role" , ChatRoomMemberRole . OWNER , 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 . ADMINISTRATOR , roleEventUser3 . getPreviousRole ( ) ) ; assertEquals ( "Unexpected new role" , ChatRoomMemberRole . OWNER , roleEventUser3 . getNewRole ( ) ) ; logger . info ( "--- End testGrantOwnership room:" + roomName ) ; }
The owner of the room (the user who created it, and which is an
 administrator too, typically user1) will grant ownership privileges 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 ownership privileges to one of our peers ( user2 ) .
// Owner of the room grants ownership privileges to user2: