getConnection(2).createPacketCollector(new MessageTypeFilter(Message.Type.normal));
PacketCollector collector3 =
getConnection(3).createPacketCollector(new MessageTypeFilter(Message.Type.normal));
// Send the intial message with multiple recipients
Message message = new Message();
message.setBody("Hola");
List to = Arrays.asList(new String[]{getBareJID(1)});
List cc = Arrays.asList(new String[]{getBareJID(2)});
List bcc = Arrays.asList(new String[]{getBareJID(3)});
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);
// Get the message and ensure it's ok
Message message1 =
(Message) collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
assertNotNull("Connection 1 never received the message", message1);
MultipleRecipientInfo info = MultipleRecipientManager.getMultipleRecipientInfo(message1);
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info);
assertFalse("Message 1 should be 'replyable'", info.shouldNotReply());
assertEquals("Incorrect number of TO addresses", 1, info.getTOAddresses().size());
assertEquals("Incorrect number of CC addresses", 1, info.getCCAddresses().size());
// Prepare and send the reply
Message reply1 = new Message();
reply1.setBody("This is my reply");
MultipleRecipientManager.reply(getConnection(1), message1, reply1);
// Get the reply and ensure it's ok
reply1 = (Message) collector0.nextResult(SmackConfiguration.getPacketReplyTimeout());
assertNotNull("Connection 0 never received the reply", reply1);
info = MultipleRecipientManager.getMultipleRecipientInfo(reply1);
assertNotNull("Replied message does not contain MultipleRecipientInfo", info);
assertFalse("Replied message should be 'replyable'", info.shouldNotReply());
assertEquals("Incorrect number of TO addresses", 1, info.getTOAddresses().size());
assertEquals("Incorrect number of CC addresses", 1, info.getCCAddresses().size());
// Send a reply to the reply
Message reply2 = new Message();
reply2.setBody("This is my reply to your reply");
reply2.setFrom(getBareJID(0));
MultipleRecipientManager.reply(getConnection(0), reply1, reply2);
// Get the reply and ensure it's ok
reply2 = (Message) collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
assertNotNull("Connection 1 never received the reply", reply2);