From 44c5f274eac871a0bb6b9da4852f04d4cc062246 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Thu, 8 Mar 2007 19:25:53 +0000 Subject: [PATCH] Added new test case for IQ packets sent to full JIDs of offline users. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7411 b35dd754-fafc-0310-a699-88a17e54d16e --- test/org/jivesoftware/smack/IQTest.java | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/org/jivesoftware/smack/IQTest.java b/test/org/jivesoftware/smack/IQTest.java index 4ddc428bd..278358d3a 100644 --- a/test/org/jivesoftware/smack/IQTest.java +++ b/test/org/jivesoftware/smack/IQTest.java @@ -26,6 +26,7 @@ import org.jivesoftware.smack.filter.PacketIDFilter; import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.test.SmackTestCase; +import org.jivesoftware.smackx.packet.Version; /** * Ensure that the server is handling IQ packets correctly. @@ -72,6 +73,32 @@ public class IQTest extends SmackTestCase { } } + /** + * Check that sending an IQ to a full JID that is offline returns an IQ ERROR instead + * of being route to some other resource of the same user. + */ + public void testFullJIDToOfflineUser() { + // Request the version from the server. + Version versionRequest = new Version(); + versionRequest.setType(IQ.Type.GET); + versionRequest.setFrom(getFullJID(0)); + versionRequest.setTo(getBareJID(0) + "/Something"); + + // Create a packet collector to listen for a response. + PacketCollector collector = getConnection(0).createPacketCollector( + new PacketIDFilter(versionRequest.getPacketID())); + + getConnection(0).sendPacket(versionRequest); + + // Wait up to 5 seconds for a result. + IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); + // Stop queuing results + collector.cancel(); + assertNotNull("No response from server", result); + assertEquals("The server didn't reply with an error packet", IQ.Type.ERROR, result.getType()); + assertEquals("Server answered an incorrect error code", 503, result.getError().getCode()); + } + protected int getMaxConnections() { return 1; }