Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-09-02 03:15:04 -0400
committerslewis2007-09-02 03:15:04 -0400
commitdbd809e2dc74215710a2ee26eca65ceeb763b9c3 (patch)
treef74feafe6c33340bcba2b445f2c9642f9bc21f93 /tests/bundles/org.eclipse.ecf.tests.presence
parent60f75ba1a67c0b69158866697fcf7a2dddd15b1d (diff)
downloadorg.eclipse.ecf-dbd809e2dc74215710a2ee26eca65ceeb763b9c3.tar.gz
org.eclipse.ecf-dbd809e2dc74215710a2ee26eca65ceeb763b9c3.tar.xz
org.eclipse.ecf-dbd809e2dc74215710a2ee26eca65ceeb763b9c3.zip
Additions and test code for enhancements for bug 197007
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.presence')
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/ChatRoomParticipantTest.java143
1 files changed, 143 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/ChatRoomParticipantTest.java b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/ChatRoomParticipantTest.java
new file mode 100755
index 000000000..52778c815
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.presence/src/org/eclipse/ecf/tests/presence/ChatRoomParticipantTest.java
@@ -0,0 +1,143 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.presence;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.user.IUser;
+import org.eclipse.ecf.presence.IPresence;
+import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
+import org.eclipse.ecf.presence.chatroom.IChatRoomInfo;
+import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
+import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
+
+/**
+ *
+ */
+public class ChatRoomParticipantTest extends PresenceAbstractTestCase {
+
+ IChatRoomContainer chatRoomContainer0, chatRoomContainer1 = null;
+ public static final int WAITTIME = 20000;
+ public static final String CHAT_ROOM_NAME = System.getProperty("chat.room.name");
+
+ protected IChatRoomParticipantListener participantListener0 = new IChatRoomParticipantListener() {
+ public void handleArrived(IUser participant) {
+ System.out.println("0.handleArrived(" + participant + ")");
+ }
+
+ public void handleDeparted(IUser participant) {
+ System.out.println("0.handleDeparted(" + participant + ")");
+ }
+
+ public void handlePresenceUpdated(ID fromID, IPresence presence) {
+ System.out.println("0.handlePresenceUpdated(" + fromID + "," + presence + ")");
+ }
+
+ public void handleUpdated(IUser updatedParticipant) {
+ System.out.println("0.handleUpdated(" + updatedParticipant + ")");
+ }
+ };
+
+ protected IChatRoomParticipantListener participantListener1 = new IChatRoomParticipantListener() {
+ public void handleArrived(IUser participant) {
+ System.out.println("1.handleArrived(" + participant + ")");
+ }
+
+ public void handleDeparted(IUser participant) {
+ System.out.println("1.handleDeparted(" + participant + ")");
+ }
+
+ public void handlePresenceUpdated(ID fromID, IPresence presence) {
+ System.out.println("0.handlePresenceUpdated(" + fromID + "," + presence + ")");
+ }
+
+ public void handleUpdated(IUser updatedParticipant) {
+ System.out.println("1.handleUpdated(" + updatedParticipant + ")");
+ }
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.presence.PresenceAbstractTestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ setClientCount(2);
+ clients = createClients();
+ IChatRoomManager chat0, chat1;
+ chat0 = getPresenceAdapter(0).getChatRoomManager();
+ chat1 = getPresenceAdapter(1).getChatRoomManager();
+ for (int i = 0; i < getClientCount(); i++) {
+ connectClient(i);
+ }
+ final IChatRoomInfo roomInfo0 = chat0.getChatRoomInfo(CHAT_ROOM_NAME);
+ chatRoomContainer0 = roomInfo0.createChatRoomContainer();
+ chatRoomContainer0.addChatRoomParticipantListener(participantListener0);
+ chatRoomContainer0.connect(roomInfo0.getRoomID(), null);
+ final IChatRoomInfo roomInfo1 = chat1.getChatRoomInfo(CHAT_ROOM_NAME);
+ chatRoomContainer1 = roomInfo1.createChatRoomContainer();
+ chatRoomContainer1.addChatRoomParticipantListener(participantListener1);
+ chatRoomContainer1.connect(roomInfo1.getRoomID(), null);
+ Thread.sleep(2000);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ disconnectClients();
+ }
+
+ public void testGetChatRoomParticipants0() throws Exception {
+ final ID[] participants = chatRoomContainer0.getChatRoomParticipants();
+ assertNotNull(participants);
+ assertTrue(participants.length == getClientCount());
+ }
+
+ public void testGetChatRoomParticipants1() throws Exception {
+ final ID[] participants = chatRoomContainer1.getChatRoomParticipants();
+ assertNotNull(participants);
+ assertTrue(participants.length == getClientCount());
+ }
+
+ public void testGetChatRoomParticipants2() throws Exception {
+ chatRoomContainer0.disconnect();
+ Thread.sleep(2000);
+ final ID[] participants = chatRoomContainer1.getChatRoomParticipants();
+ assertNotNull(participants);
+ assertTrue(participants.length == (getClientCount() - 1));
+ }
+
+ public void testGetChatRoomParticipants3() throws Exception {
+ chatRoomContainer1.disconnect();
+ final ID[] participants = chatRoomContainer1.getChatRoomParticipants();
+ assertNotNull(participants);
+ assertTrue(participants.length == 0);
+ }
+
+ public void testGetChatRoomParticipants4() throws Exception {
+ chatRoomContainer1.disconnect();
+ Thread.sleep(2000);
+ final ID[] participants = chatRoomContainer0.getChatRoomParticipants();
+ assertNotNull(participants);
+ assertTrue(participants.length == (getClientCount() - 1));
+ }
+
+ public void testGetChatRoomParticipants5() throws Exception {
+ chatRoomContainer0.disconnect();
+ final ID[] participants = chatRoomContainer0.getChatRoomParticipants();
+ assertNotNull(participants);
+ assertTrue(participants.length == 0);
+ }
+
+}

Back to the top