diff options
author | Emil Ivov <emcho@jitsi.org> | 2007-04-23 18:32:14 +0000 |
---|---|---|
committer | Emil Ivov <emcho@jitsi.org> | 2007-04-23 18:32:14 +0000 |
commit | 6e1c8a1763b7be3cafee519e15696b70561e3234 (patch) | |
tree | 1c9a0cdde255339f51eaa10ba1863c0ecf9940d9 /test | |
parent | 503c85657769a648fefd0653d314c9ca5ae52f7b (diff) | |
download | jitsi-6e1c8a1763b7be3cafee519e15696b70561e3234.zip jitsi-6e1c8a1763b7be3cafee519e15696b70561e3234.tar.gz jitsi-6e1c8a1763b7be3cafee519e15696b70561e3234.tar.bz2 |
commit the multi user chat slick
Diffstat (limited to 'test')
3 files changed, 222 insertions, 10 deletions
diff --git a/test/net/java/sip/communicator/slick/protocol/jabber/JabberProtocolProviderServiceLick.java b/test/net/java/sip/communicator/slick/protocol/jabber/JabberProtocolProviderServiceLick.java index 934f6ea..07e0801 100644 --- a/test/net/java/sip/communicator/slick/protocol/jabber/JabberProtocolProviderServiceLick.java +++ b/test/net/java/sip/communicator/slick/protocol/jabber/JabberProtocolProviderServiceLick.java @@ -43,6 +43,14 @@ public class JabberProtocolProviderServiceLick = "accounts.jabber.DISABLE_ONLINE_TESTING"; /** + * The name of the chat room that we will create and use for multi user + * chat testing. + */ + public static final String CHAT_ROOM_NAME + = "accounts.jabber.CHAT_ROOM_NAME"; + + + /** * The name of the property the value of which is a formatted string that * contains the contact list that. */ @@ -85,6 +93,8 @@ public class JabberProtocolProviderServiceLick addTest(TestOperationSetBasicInstantMessaging.suite()); addTest(TestOperationSetTypingNotifications.suite()); + /** @todo UNCOMMENT */ +// addTest(TestOperationSetMultiUserChat.suite()); } diff --git a/test/net/java/sip/communicator/slick/protocol/jabber/JabberSlickFixture.java b/test/net/java/sip/communicator/slick/protocol/jabber/JabberSlickFixture.java index 7502944..4c714e4 100644 --- a/test/net/java/sip/communicator/slick/protocol/jabber/JabberSlickFixture.java +++ b/test/net/java/sip/communicator/slick/protocol/jabber/JabberSlickFixture.java @@ -59,6 +59,13 @@ public class JabberSlickFixture */ public String userID2 = null; + /** + * The name of the chat room that we are using for testing of multi user + * chatting. + */ + public String chatRoomName = null; + + /** * The tested protocol provider factory. @@ -119,16 +126,21 @@ public class JabberSlickFixture //Keep the reference for later usage. providerFactory = (ProtocolProviderFactory)bc.getService(serRefs[0]); - userID1 = - System.getProperty( + userID1 + = System.getProperty( JabberProtocolProviderServiceLick.ACCOUNT_1_PREFIX + ProtocolProviderFactory.USER_ID); - userID2 = - System.getProperty( + userID2 + = System.getProperty( JabberProtocolProviderServiceLick.ACCOUNT_2_PREFIX + ProtocolProviderFactory.USER_ID); + chatRoomName + = System.getProperty( + JabberProtocolProviderServiceLick.CHAT_ROOM_NAME); + + //find the protocol providers exported for the two accounts ServiceReference[] jabberProvider1Refs = bc.getServiceReferences( diff --git a/test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat.java b/test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat.java index 1f421de..0699d68 100644 --- a/test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat.java +++ b/test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat.java @@ -10,6 +10,9 @@ import net.java.sip.communicator.util.*; import junit.framework.*; import net.java.sip.communicator.service.protocol.*; import java.util.*; +import net.java.sip.communicator.service.protocol.event. + ChatRoomMemberEvent; +import net.java.sip.communicator.service.protocol.event.*; /** * Creates a chat room on the server, then tries to make both users join the @@ -54,7 +57,32 @@ public class TestOperationSetMultiUserChat */ public static Test suite() { - TestSuite suite = new TestSuite(TestOperationSetMultiUserChat.class); + TestSuite suite = new TestSuite(); + + //make sure tests are executed in the right order as we need to first + //create and join the room before actually being able to send and/or + //receive messages and participant events. + suite.addTest( + new TestOperationSetMultiUserChat("testCreateChatRoom")); + suite.addTest( + new TestOperationSetMultiUserChat("testGetExistingChatRooms")); + suite.addTest( + new TestOperationSetMultiUserChat("testFindRoom")); + suite.addTest( + new TestOperationSetMultiUserChat("testOurJoin")); + suite.addTest( + new TestOperationSetMultiUserChat("testGetMembersAfterJoin")); + suite.addTest( + new TestOperationSetMultiUserChat("testParticipantJoin")); + suite.addTest( + new TestOperationSetMultiUserChat("testSendAndReceiveMessages")); + suite.addTest( + new TestOperationSetMultiUserChat("testParticipantLeave")); + suite.addTest( + new TestOperationSetMultiUserChat( + "testGetMembersAfterParticipantLeave")); + suite.addTest( + new TestOperationSetMultiUserChat("testOurLeave")); return suite; } @@ -155,11 +183,173 @@ public class TestOperationSetMultiUserChat public void testCreateChatRoom() throws Exception { - ChatRoom chatRoom1 - = opSetMultiChat1.createChatRoom("mychatroom@conference.voipgw.u-strasbg.fr", new Hashtable()); + //create room + ChatRoom testChatRoom = opSetMultiChat1 + .createChatRoom(fixture.chatRoomName, new Hashtable()); + + //get available rooms + assertNotNull("createChatRoom() returned null", testChatRoom); + + assertEquals("The name of the chat room that was " + +"created did not match the name that we wanted to have" + , fixture.chatRoomName, testChatRoom.getName()); + + assertSame( + "The newly created chat room did not had a properly set provider." + , fixture.provider1 + , testChatRoom.getParentProvider()); + } + + /** + * Retrieves existing chat room from the protocol provider and makes sure + * that the room we created in previous tests is in there. + * + * @throws Exception if an exception is thrown while retrieving existing + * chat rooms. + */ + public void testGetExistingChatRooms() + throws Exception + { + List existingChatRooms = opSetMultiChat1.getExistingChatRooms(); + + assertTrue ( + "No chat rooms found on the server, even after we " + +"have created one. " + , existingChatRooms.size() > 0); + + logger.info("Server returned the following list of chat rooms: " + + existingChatRooms); + + boolean testRoomFound = false; + + Iterator roomsIter = existingChatRooms.iterator(); + + while(roomsIter.hasNext()) + { + String roomName = (String)roomsIter.next(); + + if (roomName.equals(fixture.chatRoomName)) + testRoomFound = true; + } + + assertTrue("The room we created in previous tests " + +fixture.chatRoomName + +" was not among the existing rooms list returned by " + +"the provider." + , testRoomFound); + } + + /** + * Tries to find the test room we created previously and makes sure it looks + * as expected. + * @throws Exception if we fail finding the chat room. + */ + public void testFindRoom() + throws Exception + { + ChatRoom testChatRoom = opSetMultiChat1.findRoom(fixture.chatRoomName); + + assertNotNull("Could not find the test chat room on the server" + , testChatRoom); + + String roomName = testChatRoom.getName(); + + assertEquals("Name of the test chat room did not match the name of the " + +"room we created" + , fixture.chatRoomName, roomName); + } + + /** + * Join the chat room and verify that we are among its members + * @throws Exception + */ + public void testOurJoin() + throws Exception + { + ChatRoom testChatRoom1 + = opSetMultiChat1.findRoom(fixture.chatRoomName); + +// testChatRoom1.addParticipantStatusListener(); + + testChatRoom1.join(); + + /** @todo add event handlers for us joining the room for our status */ + + + testChatRoom1.getParentProvider(); + testChatRoom1.getUserNickname(); + + testChatRoom1.isJoined(); + + } + + public void testGetMembersAfterJoin() + { + //member count > 0 + //are we among the members? + } + + public void testParticipantJoin() + throws Exception + { + /** @todo join provider 2 */ + /** @todo make sure there was an event delivered to provider 1 saying + * that provider 2 has joined. */ + } + + public void testSendAndReceiveMessages() + throws Exception + { + ChatRoom testChatRoom = opSetMultiChat1.findRoom(fixture.chatRoomName); + + testChatRoom.sendMessage(testChatRoom.createMessage("opla")); + + /** @todo make sure there is a message at BOTH provider 1 & 2 saying + * that the message was delivered */ + /** @todo make sure there is a message at BOTH provider 1 & 2 saying + * that the message was delivered */ + } + + public void testParticipantLeave() + { + + } + + public void testGetMembersAfterParticipantLeave() + { + //are we not among the members? + } + + public void testOurLeave() + { + //are we not among the members? + } + + private class ParticipantStatusEventCollector + implements ChatRoomMemberListener + { + + /** + * Stores the received event and notifies all waiting on this object + * + * @param event the event containing the source call. + */ + public void memberStatusChanged( + ChatRoomMemberEvent evt) + { + synchronized(this) + { +// logger.debug( +// "Collected evt("+collectedEvents.size()+")= "+event); +// +// if(((CallState)event.getNewValue()).equals(awaitedState)) +// { +// this.collectedEvents.add(event); +// notifyAll(); +// } + } + } + - chatRoom1.join(); - try{ Thread.currentThread().wait(100000); }catch (InterruptedException ex){} -// chatRoom1. } } |