aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEmil Ivov <emcho@jitsi.org>2007-06-17 15:05:47 +0000
committerEmil Ivov <emcho@jitsi.org>2007-06-17 15:05:47 +0000
commita11967e5cc6aa6e0c8320ba86e63553ab5fcca1f (patch)
tree52ccd3abd1a159a26bbdc5fab0f2bcf2b40b7c36 /test
parent7a66349697cfd8197e61aea026403f96f8622cdd (diff)
downloadjitsi-a11967e5cc6aa6e0c8320ba86e63553ab5fcca1f.zip
jitsi-a11967e5cc6aa6e0c8320ba86e63553ab5fcca1f.tar.gz
jitsi-a11967e5cc6aa6e0c8320ba86e63553ab5fcca1f.tar.bz2
added a method that clears the contact list (by Benoit Pradelle)
Diffstat (limited to 'test')
-rw-r--r--test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java72
1 files changed, 27 insertions, 45 deletions
diff --git a/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java b/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java
index 28aaa51..e49953c 100644
--- a/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java
+++ b/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java
@@ -6,9 +6,7 @@
*/
package net.java.sip.communicator.slick.protocol.sip;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
import org.osgi.framework.*;
import junit.framework.*;
@@ -194,22 +192,29 @@ public class SipSlickFixture
return null;
}
+ /**
+ * Removes all contact groups and contacts currently recorded by the
+ * presence operation set of the sip providers we are using.
+ *
+ * @throws Exception if anything goes wrong and we fail to empty the contact
+ * lists.
+ */
public void clearProvidersLists()
- throws Exception
+ throws Exception
{
Map supportedOperationSets1 = provider1.getSupportedOperationSets();
-
+
if ( supportedOperationSets1 == null
|| supportedOperationSets1.size() < 1)
throw new NullPointerException(
"No OperationSet implementations are supported by "
+"this Sip implementation. ");
-
+
//get the operation set presence here.
OperationSetPersistentPresence opSetPersPresence1 =
(OperationSetPersistentPresence)supportedOperationSets1.get(
OperationSetPersistentPresence.class.getName());
-
+
//if still null then the implementation doesn't offer a presence
//operation set which is unacceptable for Sip.
if (opSetPersPresence1 == null)
@@ -217,21 +222,21 @@ public class SipSlickFixture
"An implementation of the Sip service must provide an "
+ "implementation of at least the one of the Presence "
+ "Operation Sets");
-
+
// lets do it once again for the second provider
Map supportedOperationSets2 = provider2.getSupportedOperationSets();
-
+
if (supportedOperationSets2 == null
|| supportedOperationSets2.size() < 1)
throw new NullPointerException(
"No OperationSet implementations are supported by "
+ "this Jabber implementation. ");
-
+
//get the operation set presence here.
OperationSetPersistentPresence opSetPersPresence2 =
(OperationSetPersistentPresence) supportedOperationSets2.get(
OperationSetPersistentPresence.class.getName());
-
+
//if still null then the implementation doesn't offer a presence
//operation set which is unacceptable for Sip.
if (opSetPersPresence2 == null)
@@ -239,64 +244,41 @@ public class SipSlickFixture
"An implementation of the Sip service must provide an "
+ "implementation of at least the one of the Presence "
+ "Operation Sets");
-
- ContactGroup rootGroup1 = opSetPersPresence1.getServerStoredContactListRoot();
-
+
+ ContactGroup rootGroup1
+ = opSetPersPresence1.getServerStoredContactListRoot();
+
// first delete the groups
- Vector groupsToRemove = new Vector();
Iterator iter = rootGroup1.subgroups();
while (iter.hasNext())
{
- groupsToRemove.add(iter.next());
- }
-
- iter = groupsToRemove.iterator();
- while (iter.hasNext())
- {
ContactGroup item = (ContactGroup) iter.next();
opSetPersPresence1.removeServerStoredContactGroup(item);
}
-
+
//then delete contacts if any in root list
- Vector contactsToRemove = new Vector();
iter = rootGroup1.contacts();
while (iter.hasNext())
{
- contactsToRemove.add(iter.next());
- }
- iter = contactsToRemove.iterator();
- while (iter.hasNext())
- {
opSetPersPresence1.unsubscribe((Contact)iter.next());
}
-
- ContactGroup rootGroup2 = opSetPersPresence2.getServerStoredContactListRoot();
-
+
+ ContactGroup rootGroup2
+ = opSetPersPresence2.getServerStoredContactListRoot();
+
// delete groups
- groupsToRemove = new Vector();
+
iter = rootGroup2.subgroups();
while (iter.hasNext())
{
- groupsToRemove.add(iter.next());
- }
-
- iter = groupsToRemove.iterator();
- while (iter.hasNext())
- {
ContactGroup item = (ContactGroup) iter.next();
opSetPersPresence2.removeServerStoredContactGroup(item);
}
-
+
//then delete contacts if any in root list
- contactsToRemove = new Vector();
iter = rootGroup2.contacts();
while (iter.hasNext())
{
- contactsToRemove.add(iter.next());
- }
- iter = contactsToRemove.iterator();
- while (iter.hasNext())
- {
opSetPersPresence2.unsubscribe( (Contact) iter.next());
}
}