From e7bca260bc62b0f7e6712b69cb01fe5438841e30 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Tue, 25 Jan 2005 17:26:54 +0000 Subject: [PATCH] Added test to ensure that extensions sent together with the group chat room invitation are received by the invitee. JM-135 git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2449 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/muc/MultiUserChatTest.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java b/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java index 9851b2357..b79629fd3 100644 --- a/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java +++ b/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java @@ -62,6 +62,7 @@ import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.packet.*; import org.jivesoftware.smack.test.SmackTestCase; import org.jivesoftware.smackx.Form; +import org.jivesoftware.smackx.packet.XHTMLExtension; /** * Tests the new MUC functionalities. @@ -316,6 +317,55 @@ public class MultiUserChatTest extends SmackTestCase { } } + public void testInvitationWithMessage() { + final String[] answer = new String[2]; + try { + // User2 joins the new room + MultiUserChat muc2 = new MultiUserChat(getConnection(1), room); + muc2.join("testbot2"); + + // User3 is listening to MUC invitations + MultiUserChat.addInvitationListener(getConnection(2), new InvitationListener() { + public void invitationReceived( + XMPPConnection conn, + String room, + String inviter, + String reason, + String password, + Message message) { + // Indicate that the invitation was received + answer[0] = reason; + XHTMLExtension extension = (XHTMLExtension) message.getExtension("html", + "http://jabber.org/protocol/xhtml-im"); + assertNotNull("An extension was not found in the invitation", extension); + answer[1] = (String) extension.getBodies().next(); + } + }); + + // User2 invites user3 to join to the room + Message msg = new Message(); + XHTMLExtension xhtmlExtension = new XHTMLExtension(); + xhtmlExtension.addBody("Meet me in this excellent room"); + msg.addExtension(xhtmlExtension); + muc2.invite(msg , getFullJID(2), "Meet me in this excellent room"); + Thread.sleep(350); + + assertEquals( + "Invitation was not received", + "Meet me in this excellent room", + answer[0]); + assertEquals("Rejection was not received", + "Meet me in this excellent room", answer[1]); + + // User2 leaves the room + muc2.leave(); + } + catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + public void testDiscoverJoinedRooms() { try { // Check that user1 has joined only to one room