test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetTypingNotifications.java
/**
     * Sends a typing notification and verifies
     * whether it is properly received by the tested implementation
     */
Sends a typing notification and verifies
whether it is properly received by the tested implementation
Sends a typing notification and verifies whether it is properly received by the tested implementation
public void testTypingNotificationsEventDelivery()
        throws OperationFailedException
    {
        TypingEventCollector evtCollector = new TypingEventCollector();
        Contact notifingContact =
            opSetPresence1.findContactByID(fixture.userID2);
        opSetBasicIM1.sendInstantMessage(notifingContact,
                                         opSetBasicIM1.createMessage("ping"));
        opSetTypingNotifs1.addTypingNotificationsListener(evtCollector);
        Contact contactToNotify =
            opSetPresence2.findContactByID(fixture.userID1);
        opSetTypingNotifs2.sendTypingNotification(
            contactToNotify, OperationSetTypingNotifications.STATE_TYPING);
        evtCollector.waitForEvent(10000);
        opSetTypingNotifs1.removeTypingNotificationsListener(evtCollector);
        assertTrue("Number of typing events received was zero."
            , evtCollector.collectedEvents.size() > 0);
        TypingNotificationEvent evt = (TypingNotificationEvent)evtCollector
                                                    .collectedEvents.get(0);
        assertEquals("Source of the typing notification event"
                     , fixture.userID2
                     , evt.getSourceContact().getAddress() );
        assertEquals("Source of the typing notification event"
                     , OperationSetTypingNotifications.STATE_TYPING
                     , evt.getTypingState());
        evtCollector.collectedEvents.clear();
        opSetTypingNotifs1.addTypingNotificationsListener(evtCollector);
        opSetTypingNotifs2.sendTypingNotification(
            contactToNotify, OperationSetTypingNotifications.STATE_STOPPED);
        evtCollector.waitForEvent(10000);
        opSetTypingNotifs1.removeTypingNotificationsListener(evtCollector);
        assertTrue("Number of typing events received was zero."
            , evtCollector.collectedEvents.size() > 0);
        logger.trace("We have collected " + evtCollector.collectedEvents.size()
            + " typing notifications.");
        logger.trace("Notifications: " + evtCollector.collectedEvents);
        evt = (TypingNotificationEvent)evtCollector.collectedEvents.get(0);
        assertEquals("Source of the typing notification event"
                     , fixture.userID2
                     , evt.getSourceContact().getAddress() );
        assertEquals("Source of the typing notification event"
                     , OperationSetTypingNotifications.STATE_STOPPED
                     , evt.getTypingState());
    }
public void testTypingNotificationsEventDelivery ( ) throws OperationFailedException { TypingEventCollector evtCollector = new TypingEventCollector ( ) ; Contact notifingContact = opSetPresence1 . findContactByID ( fixture . userID2 ) ; opSetBasicIM1 . sendInstantMessage ( notifingContact , opSetBasicIM1 . createMessage ( "ping" ) ) ; opSetTypingNotifs1 . addTypingNotificationsListener ( evtCollector ) ; Contact contactToNotify = opSetPresence2 . findContactByID ( fixture . userID1 ) ; opSetTypingNotifs2 . sendTypingNotification ( contactToNotify , OperationSetTypingNotifications . STATE_TYPING ) ; evtCollector . waitForEvent ( 10000 ) ; opSetTypingNotifs1 . removeTypingNotificationsListener ( evtCollector ) ; assertTrue ( "Number of typing events received was zero." , evtCollector . collectedEvents . size ( ) > 0 ) ; TypingNotificationEvent evt = ( TypingNotificationEvent ) evtCollector . collectedEvents . get ( 0 ) ; assertEquals ( "Source of the typing notification event" , fixture . userID2 , evt . getSourceContact ( ) . getAddress ( ) ) ; assertEquals ( "Source of the typing notification event" , OperationSetTypingNotifications . STATE_TYPING , evt . getTypingState ( ) ) ; evtCollector . collectedEvents . clear ( ) ; opSetTypingNotifs1 . addTypingNotificationsListener ( evtCollector ) ; opSetTypingNotifs2 . sendTypingNotification ( contactToNotify , OperationSetTypingNotifications . STATE_STOPPED ) ; evtCollector . waitForEvent ( 10000 ) ; opSetTypingNotifs1 . removeTypingNotificationsListener ( evtCollector ) ; assertTrue ( "Number of typing events received was zero." , evtCollector . collectedEvents . size ( ) > 0 ) ; logger . trace ( "We have collected " + evtCollector . collectedEvents . size ( ) + " typing notifications." ) ; logger . trace ( "Notifications: " + evtCollector . collectedEvents ) ; evt = ( TypingNotificationEvent ) evtCollector . collectedEvents . get ( 0 ) ; assertEquals ( "Source of the typing notification event" , fixture . userID2 , evt . getSourceContact ( ) . getAddress ( ) ) ; assertEquals ( "Source of the typing notification event" , OperationSetTypingNotifications . STATE_STOPPED , evt . getTypingState ( ) ) ; }
Sends a typing notification and verifies
 whether it is properly received by the tested implementation
Sends a typing notification and verifies whether it is properly received by the tested implementation
// send message so request for receiving notifications also to be set //check event dispatching //check event dispatching