Fixed test case when cleaning up roster.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3132 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-12-01 04:29:08 +00:00 committed by gato
parent 66c30903d0
commit ee6cedcea7
1 changed files with 23 additions and 16 deletions

View File

@ -423,7 +423,12 @@ public class RosterTest extends SmackTestCase {
roster.getGroup("Amigos").setName(""); roster.getGroup("Amigos").setName("");
Thread.sleep(500); // Wait up to 2 seconds for the group to change its name
initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 &&
(roster.getGroup("Amigos") != null)) {
Thread.sleep(100);
}
assertNull("The group Amigos still exists", roster.getGroup("Amigos")); assertNull("The group Amigos still exists", roster.getGroup("Amigos"));
assertNotNull("The group with no name does not exist", roster.getGroup("")); assertNotNull("The group with no name does not exist", roster.getGroup(""));
@ -520,24 +525,26 @@ public class RosterTest extends SmackTestCase {
* Clean up all the entries in the roster * Clean up all the entries in the roster
*/ */
private void cleanUpRoster() { private void cleanUpRoster() {
// Delete all the entries from the roster for (int i=0; i<getMaxConnections(); i++) {
Iterator it = getConnection(0).getRoster().getEntries(); // Delete all the entries from the roster
while (it.hasNext()) { Iterator it = getConnection(i).getRoster().getEntries();
RosterEntry entry = (RosterEntry) it.next(); while (it.hasNext()) {
try { RosterEntry entry = (RosterEntry) it.next();
getConnection(0).getRoster().removeEntry(entry); try {
} catch (XMPPException e) { getConnection(i).getRoster().removeEntry(entry);
e.printStackTrace(); } catch (XMPPException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
try {
Thread.sleep(700);
}
catch (InterruptedException e) {
fail(e.getMessage()); fail(e.getMessage());
} }
} }
try {
Thread.sleep(1500);
}
catch (InterruptedException e) {
fail(e.getMessage());
}
// Wait up to 2 seconds to receive roster removal notifications // Wait up to 2 seconds to receive roster removal notifications
long initial = System.currentTimeMillis(); long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 && while (System.currentTimeMillis() - initial < 2000 &&