test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetBasicInstantMessaging.java
/**
     * Send an instant message from the tester agent and assert reception by
     * the tested implementation
     */
Send an instant message from the tester agent and assert reception by
the tested implementation
Send an instant message from the tester agent and assert reception by the tested implementation
public void thenTestSendMessage()
        throws OperationFailedException
    {
        String body = "This is an IM coming from the tested implementation"
            + " on " + new Date().toString();
        net.java.sip.communicator.service.protocol.Message msg
            = opSetBasicIM.createMessage(body);
        ImEventCollector imEvtCollector = new ImEventCollector();
        opSetBasicIM.addMessageListener(imEvtCollector);
        JoustSimMessageEventCollector jsEvtCollector
            = new JoustSimMessageEventCollector();
        IcqSlickFixture.testerAgent.addConversationListener( fixture.ourUserID
                                                     , jsEvtCollector);
        Contact testerAgentContact
            = opSetPresence.findContactByID(IcqSlickFixture.testerAgent.getIcqUIN());
        opSetBasicIM.sendInstantMessage(testerAgentContact, msg);
        imEvtCollector.waitForEvent(10000);
        jsEvtCollector.waitForEvent(10000);
        IcqSlickFixture.testerAgent.removeConversationListener( fixture.ourUserID
                                                        , jsEvtCollector);
        opSetBasicIM.removeMessageListener(imEvtCollector);
        assertTrue( "No events delivered when sending a message"
                    , imEvtCollector.collectedEvents.size() > 0);
        assertTrue( "Received evt was not an instance of "
                    + MessageDeliveredEvent.class.getName()
                    , imEvtCollector.collectedEvents.get(0)
                                instanceof MessageDeliveredEvent);
        MessageDeliveredEvent evt
            = (MessageDeliveredEvent)imEvtCollector.collectedEvents.get(0);
        assertEquals("message destination "
                     , evt.getDestinationContact().getAddress()
                     , IcqSlickFixture.testerAgent.getIcqUIN());
        assertSame("source message", msg, evt.getSourceMessage());
        assertTrue( "No messages received by the tester agent"
                    , jsEvtCollector.collectedMessageInfo.size() > 0);
        String receivedBody = jsEvtCollector.collectedMessageInfo
                               .get(0).getMessage().getMessageBody();
        assertEquals("received message body", msg.getContent(), receivedBody);
    }
public void thenTestSendMessage ( ) throws OperationFailedException { String body = "This is an IM coming from the tested implementation" + " on " + new Date ( ) . toString ( ) ; net . java . sip . communicator . service . protocol . Message msg = opSetBasicIM . createMessage ( body ) ; ImEventCollector imEvtCollector = new ImEventCollector ( ) ; opSetBasicIM . addMessageListener ( imEvtCollector ) ; JoustSimMessageEventCollector jsEvtCollector = new JoustSimMessageEventCollector ( ) ; IcqSlickFixture . testerAgent . addConversationListener ( fixture . ourUserID , jsEvtCollector ) ; Contact testerAgentContact = opSetPresence . findContactByID ( IcqSlickFixture . testerAgent . getIcqUIN ( ) ) ; opSetBasicIM . sendInstantMessage ( testerAgentContact , msg ) ; imEvtCollector . waitForEvent ( 10000 ) ; jsEvtCollector . waitForEvent ( 10000 ) ; IcqSlickFixture . testerAgent . removeConversationListener ( fixture . ourUserID , jsEvtCollector ) ; opSetBasicIM . removeMessageListener ( imEvtCollector ) ; assertTrue ( "No events delivered when sending a message" , imEvtCollector . collectedEvents . size ( ) > 0 ) ; assertTrue ( "Received evt was not an instance of " + MessageDeliveredEvent . class . getName ( ) , imEvtCollector . collectedEvents . get ( 0 ) instanceof MessageDeliveredEvent ) ; MessageDeliveredEvent evt = ( MessageDeliveredEvent ) imEvtCollector . collectedEvents . get ( 0 ) ; assertEquals ( "message destination " , evt . getDestinationContact ( ) . getAddress ( ) , IcqSlickFixture . testerAgent . getIcqUIN ( ) ) ; assertSame ( "source message" , msg , evt . getSourceMessage ( ) ) ; assertTrue ( "No messages received by the tester agent" , jsEvtCollector . collectedMessageInfo . size ( ) > 0 ) ; String receivedBody = jsEvtCollector . collectedMessageInfo . get ( 0 ) . getMessage ( ) . getMessageBody ( ) ; assertEquals ( "received message body" , msg . getContent ( ) , receivedBody ) ; }
Send an instant message from the tester agent and assert reception by
 the tested implementation
Send an instant message from the tester agent and assert reception by the tested implementation
//create the message //register a listener in the op set //register a listener in the tester agent //verify that the message delivered event was dispatched //verify that the message has successfully arived at the destination