From 2370ace838cf5b2b6ebc26c09e90f88f4dec88d2 Mon Sep 17 00:00:00 2001 From: Martin Andre Date: Mon, 4 Jun 2007 01:25:25 +0000 Subject: [PATCH] Commited testcases for SIP IM OpSet by Benoit Pradelle. This test case may suffer from a problem in a specific situation : it is possible for an authenticated message to being resend after some time (and to be re-handled). We will activate these tests later. Benoit already sent us a patch for that. --- .../slick/protocol/sip/SipSlickFixture.java | 111 +++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) 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 b87bb97b8..28aaa51c1 100644 --- a/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java +++ b/test/net/java/sip/communicator/slick/protocol/sip/SipSlickFixture.java @@ -6,6 +6,10 @@ */ package net.java.sip.communicator.slick.protocol.sip; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + import org.osgi.framework.*; import junit.framework.*; import net.java.sip.communicator.service.protocol.*; @@ -190,5 +194,110 @@ public static Bundle findProtocolProviderBundle( return null; } - + public void clearProvidersLists() + 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) + throw new NullPointerException( + "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) + throw new NullPointerException( + "An implementation of the Sip service must provide an " + + "implementation of at least the one of the Presence " + + "Operation Sets"); + + 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(); + + // 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()); + } + } }