Improved timeout logic.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2502 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-06-17 22:24:33 +00:00 committed by gaston
parent 93ca7bc991
commit 8a48d3d11e
4 changed files with 39 additions and 11 deletions

View File

@ -99,7 +99,13 @@ public class RosterTest extends SmackTestCase {
rosterGroup.removeEntry(entry);
}
}
Thread.sleep(750);
// Wait up to 2 seconds
long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 &&
(roster.getGroupCount() != 0 &&
getConnection(2).getRoster().getEntryCount() != 2)) {
Thread.sleep(100);
}
assertEquals(
"The number of entries in connection 1 should be 1",
@ -342,7 +348,12 @@ public class RosterTest extends SmackTestCase {
roster.getGroup("Friends").setName("Amigos");
Thread.sleep(500);
// Wait up to 2 seconds
long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 &&
(roster.getGroup("Friends") != null)) {
Thread.sleep(100);
}
assertNull("The group Friends still exists", roster.getGroup("Friends"));
assertNotNull("The group Amigos does not exist", roster.getGroup("Amigos"));
@ -385,7 +396,12 @@ public class RosterTest extends SmackTestCase {
Roster roster = getConnection(0).getRoster();
roster.createEntry(getBareJID(1), "gato11", null);
Thread.sleep(500);
// Wait up to 2 seconds
long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 &&
(roster.getPresence(getBareJID(1)) == null)) {
Thread.sleep(100);
}
// Check that a presence is returned for a user
presence = roster.getPresence(getBareJID(1));
@ -505,7 +521,7 @@ public class RosterTest extends SmackTestCase {
}
protected void setUp() throws Exception {
XMPPConnection.DEBUG_ENABLED = false;
//XMPPConnection.DEBUG_ENABLED = false;
super.setUp();
}
}

View File

@ -254,8 +254,12 @@ public class MessageEventManagerTest extends SmackTestCase {
messageEventManager2.sendDisplayedNotification(getBareJID(0), msg.getPacketID());
messageEventManager2.sendComposingNotification(getBareJID(0), msg.getPacketID());
messageEventManager2.sendCancelledNotification(getBareJID(0), msg.getPacketID());
// Wait half second so that the complete test can run
Thread.sleep(500);
// Wait up to 2 seconds
long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 &&
(!results.containsAll(resultsExpected))) {
Thread.sleep(100);
}
assertTrue(
"Test failed due to bad results (1)" + resultsExpected,
resultsExpected.containsAll(results));

View File

@ -148,8 +148,12 @@ public class RosterExchangeManagerTest extends SmackTestCase {
entriesSent = getConnection(0).getRoster().getEntryCount();
entriesReceived = 0;
rosterExchangeManager1.send(getConnection(0).getRoster(), getBareJID(1));
// Wait for 1 second
Thread.sleep(300);
// Wait up to 2 seconds
long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 &&
(entriesSent != entriesReceived)) {
Thread.sleep(100);
}
}
catch (Exception e) {
fail("An error occured sending the message with the roster");
@ -203,8 +207,12 @@ public class RosterExchangeManagerTest extends SmackTestCase {
entriesSent = getConnection(0).getRoster().getEntryCount();
entriesReceived = 0;
rosterExchangeManager1.send(getConnection(0).getRoster(), getBareJID(1));
// Wait for 1 seconds
Thread.sleep(700);
// Wait up to 2 seconds
long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 &&
(entriesSent != entriesReceived)) {
Thread.sleep(100);
}
}
catch (Exception e) {
fail("An error occured sending the message with the roster");

View File

@ -1678,7 +1678,7 @@ public class MultiUserChatTest extends SmackTestCase {
// User2 leaves the room
muc2.leave();
Thread.sleep(150);
Thread.sleep(250);
// Check that ParticipantStatusListener is working OK
assertEquals(
"User1 didn't receive the event of User2 joining the room",