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 membership's role to one
     * of our peers (user2).
     * Membership means a long-life affiliation to the room, rather than being a
     * guest.
     *
     * @throws OperationNotSupportedException
     * @throws OperationFailedException
     */
The owner of the room (the user who created it, and which is an
administrator too, typically user1) will grant membership's role to one
of our peers (user2).
Membership means a long-life affiliation to the room, rather than being a
guest.


The owner of the room ( the user who created it and which is an administrator too typically user1 ) will grant membership ' s role to one of our peers ( user2 ) . Membership means a long - life affiliation to the room rather than being a guest .
public void testGrantMembership()
    throws OperationFailedException, OperationNotSupportedException
    {
        try
        {
            Thread.sleep(2000);
        }
        catch (InterruptedException ex)
        {}
        String roomName = testRoomBaseName + roomID;
        logger.info("--- Start testGrantMembership 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.grantMembership(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.GUEST, roleEventUser1.getPreviousRole());
        assertEquals("Unexpected new role",
            ChatRoomMemberRole.MEMBER, 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.GUEST, roleEventUser3.getPreviousRole());
        assertEquals("Unexpected new role",
            ChatRoomMemberRole.MEMBER, roleEventUser3.getNewRole());
        logger.info("--- End testGrantMembership room:" + roomName);
    }
public void testGrantMembership ( ) throws OperationFailedException , OperationNotSupportedException { try { Thread . sleep ( 2000 ) ; } catch ( InterruptedException ex ) { } String roomName = testRoomBaseName + roomID ; logger . info ( "--- Start testGrantMembership 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 . grantMembership ( 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 . GUEST , roleEventUser1 . getPreviousRole ( ) ) ; assertEquals ( "Unexpected new role" , ChatRoomMemberRole . MEMBER , 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 . GUEST , roleEventUser3 . getPreviousRole ( ) ) ; assertEquals ( "Unexpected new role" , ChatRoomMemberRole . MEMBER , roleEventUser3 . getNewRole ( ) ) ; logger . info ( "--- End testGrantMembership room:" + roomName ) ; }
The owner of the room (the user who created it, and which is an
 administrator too, typically user1) will grant membership's 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 membership ' s role to one of our peers ( user2 ) .
// Owner of the room grants user2 member rights: