mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-23 02:58:00 +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:
parent
c13766569e
commit
727304b25e
1 changed files with 47 additions and 4 deletions
|
@ -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 {
|
||||||
|
|
||||||
|
@ -74,7 +76,7 @@ public class PacketReaderTest extends SmackTestCase {
|
||||||
* with error code 501.
|
* with error code 501.
|
||||||
*/
|
*/
|
||||||
public void testIQNotImplemented() {
|
public void testIQNotImplemented() {
|
||||||
|
|
||||||
// Create a new type of IQ to send. The new IQ will include a
|
// Create a new type of IQ to send. The new IQ will include a
|
||||||
// non-existant namespace to cause the "feature-not-implemented" answer
|
// non-existant namespace to cause the "feature-not-implemented" answer
|
||||||
IQ iqPacket = new IQ() {
|
IQ iqPacket = new IQ() {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue