[sip-comm-cvs] CVS update: /sip-communicator/test/net/java/sip/communicator/slick/protocol/jabber/

emcho at dev.java.net emcho at dev.java.net
Mon Apr 23 20:32:17 CEST 2007


User: emcho   
Date: 2007-04-23 18:32:17+0000
Modified:
   sip-communicator/test/net/java/sip/communicator/slick/protocol/jabber/JabberProtocolProviderServiceLick.java
   sip-communicator/test/net/java/sip/communicator/slick/protocol/jabber/JabberSlickFixture.java
   sip-communicator/test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat.java

Log:
 commit the multi user chat slick

File Changes:

Directory: /sip-communicator/test/net/java/sip/communicator/slick/protocol/jabber/
==================================================================================

File [changed]: JabberProtocolProviderServiceLick.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/test/net/java/sip/communicator/slick/protocol/jabber/JabberProtocolProviderServiceLick.java?r1=1.1&r2=1.2
Delta lines:  +10 -0
--------------------
--- JabberProtocolProviderServiceLick.java	2006-09-21 09:01:28+0000	1.1
+++ JabberProtocolProviderServiceLick.java	2007-04-23 18:32:14+0000	1.2
@@ -43,6 +43,14 @@
         = "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 @@
             addTest(TestOperationSetBasicInstantMessaging.suite());
 
             addTest(TestOperationSetTypingNotifications.suite());
+            /** @todo UNCOMMENT */
+//            addTest(TestOperationSetMultiUserChat.suite());
         }
 
 

File [changed]: JabberSlickFixture.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/test/net/java/sip/communicator/slick/protocol/jabber/JabberSlickFixture.java?r1=1.2&r2=1.3
Delta lines:  +16 -4
--------------------
--- JabberSlickFixture.java	2006-09-29 11:10:57+0000	1.2
+++ JabberSlickFixture.java	2007-04-23 18:32:14+0000	1.3
@@ -59,6 +59,13 @@
      */
     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 @@
         //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(

File [changed]: TestOperationSetMultiUserChat.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/test/net/java/sip/communicator/slick/protocol/jabber/TestOperationSetMultiUserChat.java?r1=1.1&r2=1.2
Delta lines:  +196 -6
---------------------
--- TestOperationSetMultiUserChat.java	2007-03-10 14:33:18+0000	1.1
+++ TestOperationSetMultiUserChat.java	2007-04-23 18:32:14+0000	1.2
@@ -10,6 +10,9 @@
 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 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 void testCreateChatRoom()
         throws Exception
     {
-        ChatRoom chatRoom1
-            = opSetMultiChat1.createChatRoom("mychatroom at 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.
     }
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: cvs-help at sip-communicator.dev.java.net





More information about the commits mailing list