From 8576a13de78a0ecaed1a003b3dd19034401ab0ff Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Fri, 25 Aug 2006 22:58:23 +0000 Subject: [PATCH] Added new test case for offline messages with invalid XML characters. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@5069 b35dd754-fafc-0310-a699-88a17e54d16e --- test/org/jivesoftware/smack/MessageTest.java | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/org/jivesoftware/smack/MessageTest.java b/test/org/jivesoftware/smack/MessageTest.java index 217721631..72852859c 100644 --- a/test/org/jivesoftware/smack/MessageTest.java +++ b/test/org/jivesoftware/smack/MessageTest.java @@ -72,6 +72,42 @@ public class MessageTest extends SmackTestCase { } } + /** + * Send messages with invalid XML characters to offline users. Check that offline users + * are receiving them from the server. + */ + public void testOfflineMessageInvalidXML() { + // Make user2 unavailable + getConnection(1).sendPacket(new Presence(Presence.Type.unavailable)); + + try { + Thread.sleep(500); + + // User1 sends some messages to User2 which is not available at the moment + Chat chat = getConnection(0).createChat(getBareJID(1)); + chat.sendMessage("Test \f 1"); + chat.sendMessage("Test \r 1"); + + Thread.sleep(500); + + // User2 becomes available again + PacketCollector collector = getConnection(1).createPacketCollector(new MessageTypeFilter(Message.Type.CHAT)); + getConnection(1).sendPacket(new Presence(Presence.Type.available)); + + // Check that offline messages are retrieved by user2 which is now available + Message message = (Message) collector.nextResult(2500); + assertNotNull(message); + message = (Message) collector.nextResult(2000); + assertNotNull(message); + message = (Message) collector.nextResult(1000); + assertNull(message); + + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + /** * Check that two clients are able to send messages with a body of 4K characters and their * connections are not being closed.