test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat2.java
/**
     * Here we test conference messaging : sending, receiving messages and
     * corresponding events.
     */
Here we test conference messaging : sending, receiving messages and
corresponding events.
Here we test conference messaging : sending receiving messages and corresponding events .
public void testConferenceChat()
        throws OperationFailedException,
               OperationNotSupportedException
    {
        String testRoomName = testRoomBaseName + roomID++;
        logger.info("--- Start testConferenceChat room:" + testRoomName);
        ChatRoom opSet1Room =
            opSetMUC1.createChatRoom(testRoomName, null);
        opSet1Room.join();
        ChatRoom opSet2Room = opSetMUC2.findRoom(testRoomName);
        opSet2Room.join();
        String message1 = "lorem ipsum first";
        Message opSet1Message = opSet1Room.createMessage(message1);
        assertEquals("created message content differ from the one provided "
            ,message1, opSet1Message.getContent());
        MUCEventCollector opSet1RoomCollector = new MUCEventCollector(
            opSet1Room, MUCEventCollector.EVENT_MESSAGE, true);
        MUCEventCollector opSet2RoomCollector = new MUCEventCollector(
            opSet2Room, MUCEventCollector.EVENT_MESSAGE, true);
        opSet1Room.sendMessage(opSet1Message);
        opSet1RoomCollector.waitForEvent(10000);
        opSet2RoomCollector.waitForEvent(10000);
        assertEquals("user1 didn't received an event for message delivery "
            , 1, opSet1RoomCollector.collectedEvents.size());
        assertEquals("user2 didn't received the message"
            , 1, opSet2RoomCollector.collectedEvents.size());
        ChatRoomMessageDeliveredEvent deliveryEvent =
            (ChatRoomMessageDeliveredEvent)
                opSet1RoomCollector.collectedEvents.get(0);
        assertEquals("message type is not CONVERSATION_MESSAGE_DELIVERED"
            , ChatRoomMessageDeliveredEvent.CONVERSATION_MESSAGE_DELIVERED
            , deliveryEvent.getEventType());
        assertSame("the message has been delivered to another room instance"
            , opSet1Room, deliveryEvent.getSourceChatRoom());
        assertEquals(
            "delivered message differ from sent message"
            , message1, deliveryEvent.getMessage().getContent());
        ChatRoomMessageReceivedEvent messageEvent =
            (ChatRoomMessageReceivedEvent)
            opSet2RoomCollector.collectedEvents.get(0);
        assertEquals("message type is not CONVERSATION_MESSAGE_RECEIVED"
            , ChatRoomMessageReceivedEvent.CONVERSATION_MESSAGE_RECEIVED
            , messageEvent.getEventType());
        assertSame("the message comes from another room instance"
            , opSet2Room, messageEvent.getSourceChatRoom());
        ChatRoomMember member = messageEvent.getSourceChatRoomMember();
        assertEquals("message comes from an unexpected user"
            , opSet1Room.getUserNickname(), member.getName());
        assertEquals(
            "received message differ from sent message"
            , message1, messageEvent.getMessage().getContent());
        logger.info("--- End testConferenceChat room:" + testRoomName);
    }
public void testConferenceChat ( ) throws OperationFailedException , OperationNotSupportedException { String testRoomName = testRoomBaseName + roomID ++ ; logger . info ( "--- Start testConferenceChat room:" + testRoomName ) ; ChatRoom opSet1Room = opSetMUC1 . createChatRoom ( testRoomName , null ) ; opSet1Room . join ( ) ; ChatRoom opSet2Room = opSetMUC2 . findRoom ( testRoomName ) ; opSet2Room . join ( ) ; String message1 = "lorem ipsum first" ; Message opSet1Message = opSet1Room . createMessage ( message1 ) ; assertEquals ( "created message content differ from the one provided " , message1 , opSet1Message . getContent ( ) ) ; MUCEventCollector opSet1RoomCollector = new MUCEventCollector ( opSet1Room , MUCEventCollector . EVENT_MESSAGE , true ) ; MUCEventCollector opSet2RoomCollector = new MUCEventCollector ( opSet2Room , MUCEventCollector . EVENT_MESSAGE , true ) ; opSet1Room . sendMessage ( opSet1Message ) ; opSet1RoomCollector . waitForEvent ( 10000 ) ; opSet2RoomCollector . waitForEvent ( 10000 ) ; assertEquals ( "user1 didn't received an event for message delivery " , 1 , opSet1RoomCollector . collectedEvents . size ( ) ) ; assertEquals ( "user2 didn't received the message" , 1 , opSet2RoomCollector . collectedEvents . size ( ) ) ; ChatRoomMessageDeliveredEvent deliveryEvent = ( ChatRoomMessageDeliveredEvent ) opSet1RoomCollector . collectedEvents . get ( 0 ) ; assertEquals ( "message type is not CONVERSATION_MESSAGE_DELIVERED" , ChatRoomMessageDeliveredEvent . CONVERSATION_MESSAGE_DELIVERED , deliveryEvent . getEventType ( ) ) ; assertSame ( "the message has been delivered to another room instance" , opSet1Room , deliveryEvent . getSourceChatRoom ( ) ) ; assertEquals ( "delivered message differ from sent message" , message1 , deliveryEvent . getMessage ( ) . getContent ( ) ) ; ChatRoomMessageReceivedEvent messageEvent = ( ChatRoomMessageReceivedEvent ) opSet2RoomCollector . collectedEvents . get ( 0 ) ; assertEquals ( "message type is not CONVERSATION_MESSAGE_RECEIVED" , ChatRoomMessageReceivedEvent . CONVERSATION_MESSAGE_RECEIVED , messageEvent . getEventType ( ) ) ; assertSame ( "the message comes from another room instance" , opSet2Room , messageEvent . getSourceChatRoom ( ) ) ; ChatRoomMember member = messageEvent . getSourceChatRoomMember ( ) ; assertEquals ( "message comes from an unexpected user" , opSet1Room . getUserNickname ( ) , member . getName ( ) ) ; assertEquals ( "received message differ from sent message" , message1 , messageEvent . getMessage ( ) . getContent ( ) ) ; logger . info ( "--- End testConferenceChat room:" + testRoomName ) ; }
Here we test conference messaging : sending, receiving messages and
 corresponding events.
Here we test conference messaging : sending receiving messages and corresponding events .
// we create the test room // building and checking the message // ship it // does every member received the message // what happened on user2 side