test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat2.java
/**
     * In <tt>testNickName</tt>, user nicknames will be changed
     * and we will check if changes are well reflected on both user
     * sides.
     */
In testNickName, user nicknames will be changed
and we will check if changes are well reflected on both user
sides.
In testNickName user nicknames will be changed and we will check if changes are well reflected on both user sides .
public void testNickName()
        throws OperationFailedException,
               OperationNotSupportedException
    {
        String testRoomName = testRoomBaseName + roomID++;
        ChatRoom opSet1Room =
            opSetMUC1.createChatRoom(testRoomName, null);
        opSet1Room.join();
        String user1FirstNick = opSet1Room.getUserNickname();
        String user1SecondNick = "user1nickchange";
        ChatRoom opSet2Room = opSetMUC2.findRoom(testRoomName);
        opSet2Room.join();
        assertTrue("user nickname not found by peer "
            , nameIsOnMemberList(user1FirstNick, opSet2Room.getMembers()));
        MUCEventCollector opSet2RoomCollector =
            new MUCEventCollector(opSet2Room, MUCEventCollector.EVENT_PROPERTY);
        opSet1Room.setUserNickname(user1SecondNick);
        assertEquals("failed to change user nickname"
            , user1SecondNick, opSet1Room.getUserNickname());
        assertTrue(
            "user nickname not found on member list after modification"
            , nameIsOnMemberList(user1SecondNick, opSet1Room.getMembers()));
        opSet2RoomCollector.waitForEvent(10000);
        assertEquals("no event received since a member changed his nick"
            , 1, opSet2RoomCollector.collectedEvents.size());
        ChatRoomMemberPropertyChangeEvent changeEvent =
            (ChatRoomMemberPropertyChangeEvent)
            opSet2RoomCollector.collectedEvents.get(0);
        assertEquals("the change event doesnt comes from the expected member"
            , fixture.userID1
            , changeEvent.getSourceChatRoomMember().getContactAddress());
        assertTrue("user nickname not found on member list after modification, " +
            "from peer side",
            nameIsOnMemberList(user1SecondNick, opSet2Room.getMembers()));
        assertFalse(
            "both old and new nick are listed in a room after nick change"
            , nameIsOnMemberList(user1FirstNick, opSet1Room.getMembers()));
        assertFalse(
            "both old and new nick are listed in a room after nick change, " +
            "from the peer side",
            nameIsOnMemberList(user1FirstNick, opSet2Room.getMembers()));
        try
        {
            opSet2Room.setUserNickname(user1SecondNick);
        }
        catch (OperationFailedException ex)
        {
        }
        if (opSet1Room.getUserNickname().equals(opSet2Room.getUserNickname()))
        {
            fail(
                "different users are holding the same nick in the same room");
        }
    }
public void testNickName ( ) throws OperationFailedException , OperationNotSupportedException { String testRoomName = testRoomBaseName + roomID ++ ; ChatRoom opSet1Room = opSetMUC1 . createChatRoom ( testRoomName , null ) ; opSet1Room . join ( ) ; String user1FirstNick = opSet1Room . getUserNickname ( ) ; String user1SecondNick = "user1nickchange" ; ChatRoom opSet2Room = opSetMUC2 . findRoom ( testRoomName ) ; opSet2Room . join ( ) ; assertTrue ( "user nickname not found by peer " , nameIsOnMemberList ( user1FirstNick , opSet2Room . getMembers ( ) ) ) ; MUCEventCollector opSet2RoomCollector = new MUCEventCollector ( opSet2Room , MUCEventCollector . EVENT_PROPERTY ) ; opSet1Room . setUserNickname ( user1SecondNick ) ; assertEquals ( "failed to change user nickname" , user1SecondNick , opSet1Room . getUserNickname ( ) ) ; assertTrue ( "user nickname not found on member list after modification" , nameIsOnMemberList ( user1SecondNick , opSet1Room . getMembers ( ) ) ) ; opSet2RoomCollector . waitForEvent ( 10000 ) ; assertEquals ( "no event received since a member changed his nick" , 1 , opSet2RoomCollector . collectedEvents . size ( ) ) ; ChatRoomMemberPropertyChangeEvent changeEvent = ( ChatRoomMemberPropertyChangeEvent ) opSet2RoomCollector . collectedEvents . get ( 0 ) ; assertEquals ( "the change event doesnt comes from the expected member" , fixture . userID1 , changeEvent . getSourceChatRoomMember ( ) . getContactAddress ( ) ) ; assertTrue ( "user nickname not found on member list after modification, " + "from peer side" , nameIsOnMemberList ( user1SecondNick , opSet2Room . getMembers ( ) ) ) ; assertFalse ( "both old and new nick are listed in a room after nick change" , nameIsOnMemberList ( user1FirstNick , opSet1Room . getMembers ( ) ) ) ; assertFalse ( "both old and new nick are listed in a room after nick change, " + "from the peer side" , nameIsOnMemberList ( user1FirstNick , opSet2Room . getMembers ( ) ) ) ; try { opSet2Room . setUserNickname ( user1SecondNick ) ; } catch ( OperationFailedException ex ) { } if ( opSet1Room . getUserNickname ( ) . equals ( opSet2Room . getUserNickname ( ) ) ) { fail ( "different users are holding the same nick in the same room" ) ; } }
In <tt>testNickName</tt>, user nicknames will be changed
 and we will check if changes are well reflected on both user
 sides.
In <tt > testNickName< / tt > user nicknames will be changed and we will check if changes are well reflected on both user sides .
// we create the test room // checking the nickname from the peer side // change the nickname //user should be listed with his new nick name // user2 have to wait for the event //previous nickname should not rest on the list after change // trying to steal a nickname // stealing nickname is not allowed by the room