1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-23 06:42:05 +01:00

Added new test case for errors text with no description. SMACK-165

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@5062 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-08-25 20:20:39 +00:00 committed by gato
parent c13766569e
commit 727304b25e

View file

@ -52,12 +52,14 @@
package org.jivesoftware.smack; package org.jivesoftware.smack;
import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.PacketIDFilter; import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.MockPacketFilter; import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.test.SmackTestCase; import org.jivesoftware.smack.test.SmackTestCase;
import java.util.Date;
public class PacketReaderTest extends SmackTestCase { public class PacketReaderTest extends SmackTestCase {
@ -121,6 +123,47 @@ public class PacketReaderTest extends SmackTestCase {
getConnection(0).packetReader.listeners.size()); getConnection(0).packetReader.listeners.size());
} }
/**
* Checks that parser still works when receiving an error text with no description.
*/
public void testErrorWithNoText() {
// Send a regular message from user0 to user1
Message packet = new Message();
packet.setFrom(getFullJID(0));
packet.setTo(getFullJID(1));
packet.setBody("aloha");
// User1 will always reply to user0 when a message is received
getConnection(1).addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
System.out.println(new Date() + " " + packet);
Message message = new Message(packet.getFrom());
message.setFrom(getFullJID(1));
message.setBody("HELLO");
getConnection(1).sendPacket(message);
}
}, new PacketTypeFilter(Message.class));
// User0 listen for replies from user1
PacketCollector collector = getConnection(0).createPacketCollector(
new FromMatchesFilter(getFullJID(1)));
// User0 sends the regular message to user1
getConnection(0).sendPacket(packet);
// Check that user0 got a reply from user1
assertNotNull("No message was received", collector.nextResult(1000));
// Send a message with an empty error text
packet = new Message();
packet.setFrom(getFullJID(0));
packet.setTo(getFullJID(1));
packet.setBody("aloha");
packet.setError(new XMPPError(XMPPError.Condition.feature_not_implemented, null));
getConnection(0).sendPacket(packet);
// Check that user0 got a reply from user1
assertNotNull("No message was received", collector.nextResult(1000));
}
protected int getMaxConnections() { protected int getMaxConnections() {
return 2; return 2;
} }