From 595d1bf1d364f4d09e9a6566eb315970281d257c Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Fri, 29 Sep 2006 11:10:57 +0000 Subject: [PATCH] Fix clear lists . to clear unfiled entries if any --- .../protocol/jabber/JabberSlickFixture.java | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) 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 62629f136..7502944dd 100644 --- a/test/net/java/sip/communicator/slick/protocol/jabber/JabberSlickFixture.java +++ b/test/net/java/sip/communicator/slick/protocol/jabber/JabberSlickFixture.java @@ -1,6 +1,3 @@ - - - /* * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. * @@ -217,6 +214,7 @@ public static Bundle findProtocolProviderBundle( } public void clearProvidersLists() + throws Exception { Map supportedOperationSets1 = provider1.getSupportedOperationSets(); @@ -263,6 +261,7 @@ public void clearProvidersLists() ContactGroup rootGroup1 = opSetPersPresence1.getServerStoredContactListRoot(); + // first delete the groups Vector groupsToRemove = new Vector(); Iterator iter = rootGroup1.subgroups(); while (iter.hasNext()) @@ -277,8 +276,22 @@ public void clearProvidersLists() 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()) @@ -292,5 +305,18 @@ public void clearProvidersLists() 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()); + } } }