From 5386c77c7fb218c1117416c7266580a6ccf420c5 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Fri, 31 Dec 2004 04:31:12 +0000 Subject: [PATCH] Added test for anonymous users joining a room. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2441 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/muc/MultiUserChatTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java b/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java index d154fab70..48bb67b21 100644 --- a/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java +++ b/test/org/jivesoftware/smackx/muc/MultiUserChatTest.java @@ -234,6 +234,38 @@ public class MultiUserChatTest extends SmackTestCase { } } + public void testAnonymousParticipant() { + try { + // Anonymous user joins the new room + XMPPConnection anonConnection = new XMPPConnection(getHost(), getPort()); + anonConnection.loginAnonymously(); + MultiUserChat muc2 = new MultiUserChat(anonConnection, room); + muc2.join("testbot2"); + Thread.sleep(400); + + // User1 checks the presence of Anonymous user in the room + Presence presence = muc.getOccupantPresence(room + "/testbot2"); + assertNotNull("Presence of user2 in room is missing", presence); + assertEquals( + "Presence mode of user2 is wrong", + Presence.Mode.AVAILABLE, + presence.getMode()); + + // Anonymous user leaves the room + muc2.leave(); + anonConnection.close(); + Thread.sleep(250); + // User1 checks the presence of Anonymous user in the room + presence = muc.getOccupantPresence(room + "/testbot2"); + assertNull("Presence of participant testbotII still exists", presence); + + } + catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + public void testInvitation() { final String[] answer = new String[2]; try {