test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat2.java
/**
     * In <tt>testMemberBan</tt>, a member joins, then he is banned
     * and try to join again
     */
In testMemberBan, a member joins, then he is banned
and try to join again
In testMemberBan a member joins then he is banned and try to join again
public void testMemberBan()
        throws OperationFailedException,
        OperationNotSupportedException
    {
        try
        {
            Thread.sleep(2000);
        }
        catch (InterruptedException ex)
        {}
        String testRoomName = testRoomBaseName + roomID++;
        logger.info("--- Start testMemberBan 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 memberToBan = null;
        for (ChatRoomMember member : members)
            if (member.getContactAddress().equals(fixture.userID2))
            {
                memberToBan = member;
                break;
            }
        if (memberToBan == null)
            throw new IllegalStateException("member to ban not found");
        opSet1RoomCollector =
            new MUCEventCollector(
            opSet1Room, MUCEventCollector.EVENT_ROLE);
        assertTrue("user2 not in a room he joined "
            , opSet2Room.isJoined());
        MUCEventCollector opSet2RoomCollector =
            new MUCEventCollector(
            opSet2Room, MUCEventCollector.EVENT_PRESENCE);
        opSet1Room.banParticipant(memberToBan, "testMemberBan");
        opSet2RoomCollector.waitForEvent(2000);
        assertFalse("user2 still in a room after been banned"
            , opSet2Room.isJoined());
        opSet1RoomCollector.waitForEvent(10000);
        assertEquals("user1 didnt received an event for user2 ban"
            , 1, opSet1RoomCollector.collectedEvents.size());
        assertFalse("user2 still on member list after ban"
            , nameIsOnMemberList(fixture.userID2, opSet1Room.getMembers()));
        try
        {
            opSet2Room.join();
        }
        catch (Exception ex)
        {
        }
        assertFalse("user2 just joined a room where he is banned"
            , opSet2Room.isJoined());
        logger.info("--- End testMemberBan room:" + testRoomName);
    }
public void testMemberBan ( ) throws OperationFailedException , OperationNotSupportedException { try { Thread . sleep ( 2000 ) ; } catch ( InterruptedException ex ) { } String testRoomName = testRoomBaseName + roomID ++ ; logger . info ( "--- Start testMemberBan 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 memberToBan = null ; for ( ChatRoomMember member : members ) if ( member . getContactAddress ( ) . equals ( fixture . userID2 ) ) { memberToBan = member ; break ; } if ( memberToBan == null ) throw new IllegalStateException ( "member to ban not found" ) ; opSet1RoomCollector = new MUCEventCollector ( opSet1Room , MUCEventCollector . EVENT_ROLE ) ; assertTrue ( "user2 not in a room he joined " , opSet2Room . isJoined ( ) ) ; MUCEventCollector opSet2RoomCollector = new MUCEventCollector ( opSet2Room , MUCEventCollector . EVENT_PRESENCE ) ; opSet1Room . banParticipant ( memberToBan , "testMemberBan" ) ; opSet2RoomCollector . waitForEvent ( 2000 ) ; assertFalse ( "user2 still in a room after been banned" , opSet2Room . isJoined ( ) ) ; opSet1RoomCollector . waitForEvent ( 10000 ) ; assertEquals ( "user1 didnt received an event for user2 ban" , 1 , opSet1RoomCollector . collectedEvents . size ( ) ) ; assertFalse ( "user2 still on member list after ban" , nameIsOnMemberList ( fixture . userID2 , opSet1Room . getMembers ( ) ) ) ; try { opSet2Room . join ( ) ; } catch ( Exception ex ) { } assertFalse ( "user2 just joined a room where he is banned" , opSet2Room . isJoined ( ) ) ; logger . info ( "--- End testMemberBan room:" + testRoomName ) ; }
In <tt>testMemberBan</tt>, a member joins, then he is banned
 and try to join again
In <tt > testMemberBan< / 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 still been reported as joined on his side. // user2 has not been only kicked but banned so // he must not be able to join