test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat2.java
/**
     * In <tt>testMemberKick</tt>, a member joins, then he is banned
     * and try to join again
     */
In testMemberKick, a member joins, then he is banned
and try to join again
In testMemberKick a member joins then he is banned and try to join again
public void testMemberKick()
        throws OperationFailedException,
        OperationNotSupportedException
    {
        try
        {
            Thread.sleep(2000);
        }
        catch (InterruptedException ex)
        {}
        String testRoomName = testRoomBaseName + roomID++;
        logger.info("--- Start testMemberKick room:" + testRoomName);
        ChatRoom opSet1Room =
            opSetMUC1.createChatRoom(testRoomName, null);
        opSet1Room.join();
        MUCEventCollector opSet1RoomCollector =
            new MUCEventCollector(
            opSet1Room, MUCEventCollector.EVENT_PRESENCE);
        ChatRoom opSet2Room = opSetMUC2.findRoom(testRoomName);
        opSet2Room.join();
        opSet1RoomCollector.waitForEvent(10000);
        assertTrue("user2 not on member list after join"
            , nameIsOnMemberList(fixture.userID2, opSet1Room.getMembers()));
        List<ChatRoomMember> members = opSet1Room.getMembers();
        ChatRoomMember memberToKick = null;
        for (ChatRoomMember member : members)
            if (member.getContactAddress().equals(fixture.userID2))
            {
                memberToKick = member;
                break;
            }
        if (memberToKick == null)
            throw new IllegalStateException("member to kick not found");
        opSet1RoomCollector =
            new MUCEventCollector(
            opSet1Room, MUCEventCollector.EVENT_PRESENCE);
        assertTrue("user2 not in a room he joined "
            , opSet2Room.isJoined());
        MUCEventCollector opSet2RoomCollector =
            new MUCEventCollector(
            opSet2Room, MUCEventCollector.EVENT_PRESENCE);
        opSet1Room.kickParticipant(memberToKick, "testMemberKick");
        opSet2RoomCollector.waitForEvent(2000);
        assertFalse("user2 still in a room after been kicked"
            , opSet2Room.isJoined());
        opSet1RoomCollector.waitForEvent(10000);
        assertEquals("user1 didnt received an event for user2 kick"
            , 1, opSet1RoomCollector.collectedEvents.size());
        ChatRoomMemberPresenceChangeEvent changeEvent =
            (ChatRoomMemberPresenceChangeEvent)
            opSet1RoomCollector.collectedEvents.get(0);
        assertEquals("the event received by user1 is not "
            , ChatRoomMemberPresenceChangeEvent.MEMBER_KICKED
            , changeEvent.getEventType());
        assertEquals("the kicked member is not the one expected"
            , memberToKick.getContactAddress()
            , changeEvent.getChatRoomMember().getContactAddress());
        assertFalse("user2 still on member list after kick"
            , nameIsOnMemberList(fixture.userID2, opSet1Room.getMembers()));
        opSet2Room.join();
        assertTrue("user2 can't join after been kicked "
            , opSet2Room.isJoined());
        opSet1RoomCollector.waitForEvent(10000);
        assertTrue("user2 not on list when joining after a kick"
            , nameIsOnMemberList(fixture.userID2, opSet1Room.getMembers()));
        logger.info("--- End testMemberKick room:" + testRoomName);
    }
public void testMemberKick ( ) throws OperationFailedException , OperationNotSupportedException { try { Thread . sleep ( 2000 ) ; } catch ( InterruptedException ex ) { } String testRoomName = testRoomBaseName + roomID ++ ; logger . info ( "--- Start testMemberKick room:" + testRoomName ) ; ChatRoom opSet1Room = opSetMUC1 . createChatRoom ( testRoomName , null ) ; opSet1Room . join ( ) ; MUCEventCollector opSet1RoomCollector = new MUCEventCollector ( opSet1Room , MUCEventCollector . EVENT_PRESENCE ) ; ChatRoom opSet2Room = opSetMUC2 . findRoom ( testRoomName ) ; opSet2Room . join ( ) ; opSet1RoomCollector . waitForEvent ( 10000 ) ; assertTrue ( "user2 not on member list after join" , nameIsOnMemberList ( fixture . userID2 , opSet1Room . getMembers ( ) ) ) ; List < ChatRoomMember > members = opSet1Room . getMembers ( ) ; ChatRoomMember memberToKick = null ; for ( ChatRoomMember member : members ) if ( member . getContactAddress ( ) . equals ( fixture . userID2 ) ) { memberToKick = member ; break ; } if ( memberToKick == null ) throw new IllegalStateException ( "member to kick not found" ) ; opSet1RoomCollector = new MUCEventCollector ( opSet1Room , MUCEventCollector . EVENT_PRESENCE ) ; assertTrue ( "user2 not in a room he joined " , opSet2Room . isJoined ( ) ) ; MUCEventCollector opSet2RoomCollector = new MUCEventCollector ( opSet2Room , MUCEventCollector . EVENT_PRESENCE ) ; opSet1Room . kickParticipant ( memberToKick , "testMemberKick" ) ; opSet2RoomCollector . waitForEvent ( 2000 ) ; assertFalse ( "user2 still in a room after been kicked" , opSet2Room . isJoined ( ) ) ; opSet1RoomCollector . waitForEvent ( 10000 ) ; assertEquals ( "user1 didnt received an event for user2 kick" , 1 , opSet1RoomCollector . collectedEvents . size ( ) ) ; ChatRoomMemberPresenceChangeEvent changeEvent = ( ChatRoomMemberPresenceChangeEvent ) opSet1RoomCollector . collectedEvents . get ( 0 ) ; assertEquals ( "the event received by user1 is not " , ChatRoomMemberPresenceChangeEvent . MEMBER_KICKED , changeEvent . getEventType ( ) ) ; assertEquals ( "the kicked member is not the one expected" , memberToKick . getContactAddress ( ) , changeEvent . getChatRoomMember ( ) . getContactAddress ( ) ) ; assertFalse ( "user2 still on member list after kick" , nameIsOnMemberList ( fixture . userID2 , opSet1Room . getMembers ( ) ) ) ; opSet2Room . join ( ) ; assertTrue ( "user2 can't join after been kicked " , opSet2Room . isJoined ( ) ) ; opSet1RoomCollector . waitForEvent ( 10000 ) ; assertTrue ( "user2 not on list when joining after a kick" , nameIsOnMemberList ( fixture . userID2 , opSet1Room . getMembers ( ) ) ) ; logger . info ( "--- End testMemberKick room:" + testRoomName ) ; }
In <tt>testMemberKick</tt>, a member joins, then he is banned
 and try to join again
In <tt > testMemberKick< / tt > a member joins then he is banned and try to join again
// we create the test room // when an user is kicked or banned, the smack lib deliver corresponding // events to remaining room members but nothing to the kicked or banned // user. altough, if we dont wait some amount of time, the banned user // could stils been reported as joined on his side. // contrary to a ban, an user can join after been kicked