/** * Send an instant message from the tester agent and assert reception by the tested implementation */ public void thenTestSendMessage() { logger.debug( "Printing Server Stored list to see if message fails are contacts in each other lists"); ContactGroup rootGroup1 = ((OperationSetPersistentPresence) opSetPresence1).getServerStoredContactListRoot(); logger.debug("=========== Server Stored Contact List 1 ================="); logger.debug( "rootGroup=" + rootGroup1.getGroupName() + " rootGroup.childContacts=" + rootGroup1.countContacts() + "rootGroup.childGroups=" + rootGroup1.countSubgroups() + "Printing rootGroupContents=\n" + rootGroup1.toString()); ContactGroup rootGroup2 = ((OperationSetPersistentPresence) opSetPresence2).getServerStoredContactListRoot(); logger.debug("=========== Server Stored Contact List 2 ================="); logger.debug( "rootGroup=" + rootGroup2.getGroupName() + " rootGroup.childContacts=" + rootGroup2.countContacts() + "rootGroup.childGroups=" + rootGroup2.countSubgroups() + "Printing rootGroupContents=\n" + rootGroup2.toString()); String body = "This is an IM coming from the tested implementation" + " on " + new Date().toString(); // create the message net.java.sip.communicator.service.protocol.Message msg = opSetBasicIM1.createMessage(body); // register a listener in the op set ImEventCollector imEvtCollector1 = new ImEventCollector(); opSetBasicIM1.addMessageListener(imEvtCollector1); // register a listener in the tester agent ImEventCollector imEvtCollector2 = new ImEventCollector(); opSetBasicIM2.addMessageListener(imEvtCollector2); Contact testerAgentContact = opSetPresence1.findContactByID(fixture.userID2); opSetBasicIM1.sendInstantMessage(testerAgentContact, msg); imEvtCollector1.waitForEvent(10000); imEvtCollector2.waitForEvent(10000); opSetBasicIM1.removeMessageListener(imEvtCollector1); opSetBasicIM2.removeMessageListener(imEvtCollector2); // verify that the message delivered event was dispatched assertTrue( "No events delivered when sending a message", imEvtCollector1.collectedEvents.size() > 0); assertTrue( "Received evt was not an instance of " + MessageDeliveredEvent.class.getName(), imEvtCollector1.collectedEvents.get(0) instanceof MessageDeliveredEvent); MessageDeliveredEvent evt = (MessageDeliveredEvent) imEvtCollector1.collectedEvents.get(0); assertEquals("message destination ", evt.getDestinationContact().getAddress(), fixture.userID2); assertSame("source message", msg, evt.getSourceMessage()); // verify that the message has successfully arived at the destination assertTrue( "No messages received by the tester agent", imEvtCollector2.collectedEvents.size() > 0); assertFalse( "Message was unable to deliver !", imEvtCollector2.collectedEvents.get(0) instanceof MessageDeliveryFailedEvent); String receivedBody = ((MessageReceivedEvent) imEvtCollector2.collectedEvents.get(0)) .getSourceMessage() .getContent(); assertEquals("received message body", msg.getContent(), receivedBody); }