Need help with the code snippet below. I was trying the below example but could not make it work.
public void testHugeMessage() {
getConnection(0).sendPacket(new Presence(Presence.Type.available));
getConnection(1).sendPacket(new Presence(Presence.Type.available));
// User2 becomes available again
PacketCollector collector = getConnection(1).createPacketCollector(
new MessageTypeFilter(Message.Type.chat));
// Create message with a body of 4K characters
Message msg = new Message(getFullJID(1), Message.Type.chat);
StringBuilder sb = new StringBuilder(5000);
for (int i = 0; i <= 4000; i++) {
sb.append(“X”);
}
msg.setBody(sb.toString());
// Send the first message
getConnection(0).sendPacket(msg);
// Check that the connection that sent the message is still connected
assertTrue(“Connection was closed”, getConnection(0).isConnected());
// Check that the message was received
Message rcv = (Message) collector.nextResult(1000);
assertNotNull(“No Message was received”, rcv);
}
The test fails because collector.nextResult(1000) returns NULL. Is there something I am missing? Please let me know. I tried increasing the timeout value to 5000 ms also.
I am sure message send and receive is working because I have checked it manually.
Thanks in advance.
Message was edited by: user1-user1
Message was edited by: user1-user1