mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 22:12:05 +01:00
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:
parent
93ca7bc991
commit
8a48d3d11e
4 changed files with 39 additions and 11 deletions
|
@ -99,7 +99,13 @@ public class RosterTest extends SmackTestCase {
|
||||||
rosterGroup.removeEntry(entry);
|
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(
|
assertEquals(
|
||||||
"The number of entries in connection 1 should be 1",
|
"The number of entries in connection 1 should be 1",
|
||||||
|
@ -342,7 +348,12 @@ public class RosterTest extends SmackTestCase {
|
||||||
|
|
||||||
roster.getGroup("Friends").setName("Amigos");
|
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"));
|
assertNull("The group Friends still exists", roster.getGroup("Friends"));
|
||||||
assertNotNull("The group Amigos does not exist", roster.getGroup("Amigos"));
|
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 roster = getConnection(0).getRoster();
|
||||||
roster.createEntry(getBareJID(1), "gato11", null);
|
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
|
// Check that a presence is returned for a user
|
||||||
presence = roster.getPresence(getBareJID(1));
|
presence = roster.getPresence(getBareJID(1));
|
||||||
|
@ -505,7 +521,7 @@ public class RosterTest extends SmackTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
XMPPConnection.DEBUG_ENABLED = false;
|
//XMPPConnection.DEBUG_ENABLED = false;
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -254,8 +254,12 @@ public class MessageEventManagerTest extends SmackTestCase {
|
||||||
messageEventManager2.sendDisplayedNotification(getBareJID(0), msg.getPacketID());
|
messageEventManager2.sendDisplayedNotification(getBareJID(0), msg.getPacketID());
|
||||||
messageEventManager2.sendComposingNotification(getBareJID(0), msg.getPacketID());
|
messageEventManager2.sendComposingNotification(getBareJID(0), msg.getPacketID());
|
||||||
messageEventManager2.sendCancelledNotification(getBareJID(0), msg.getPacketID());
|
messageEventManager2.sendCancelledNotification(getBareJID(0), msg.getPacketID());
|
||||||
// Wait half second so that the complete test can run
|
// Wait up to 2 seconds
|
||||||
Thread.sleep(500);
|
long initial = System.currentTimeMillis();
|
||||||
|
while (System.currentTimeMillis() - initial < 2000 &&
|
||||||
|
(!results.containsAll(resultsExpected))) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
assertTrue(
|
assertTrue(
|
||||||
"Test failed due to bad results (1)" + resultsExpected,
|
"Test failed due to bad results (1)" + resultsExpected,
|
||||||
resultsExpected.containsAll(results));
|
resultsExpected.containsAll(results));
|
||||||
|
|
|
@ -148,8 +148,12 @@ public class RosterExchangeManagerTest extends SmackTestCase {
|
||||||
entriesSent = getConnection(0).getRoster().getEntryCount();
|
entriesSent = getConnection(0).getRoster().getEntryCount();
|
||||||
entriesReceived = 0;
|
entriesReceived = 0;
|
||||||
rosterExchangeManager1.send(getConnection(0).getRoster(), getBareJID(1));
|
rosterExchangeManager1.send(getConnection(0).getRoster(), getBareJID(1));
|
||||||
// Wait for 1 second
|
// Wait up to 2 seconds
|
||||||
Thread.sleep(300);
|
long initial = System.currentTimeMillis();
|
||||||
|
while (System.currentTimeMillis() - initial < 2000 &&
|
||||||
|
(entriesSent != entriesReceived)) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
fail("An error occured sending the message with the roster");
|
fail("An error occured sending the message with the roster");
|
||||||
|
@ -203,8 +207,12 @@ public class RosterExchangeManagerTest extends SmackTestCase {
|
||||||
entriesSent = getConnection(0).getRoster().getEntryCount();
|
entriesSent = getConnection(0).getRoster().getEntryCount();
|
||||||
entriesReceived = 0;
|
entriesReceived = 0;
|
||||||
rosterExchangeManager1.send(getConnection(0).getRoster(), getBareJID(1));
|
rosterExchangeManager1.send(getConnection(0).getRoster(), getBareJID(1));
|
||||||
// Wait for 1 seconds
|
// Wait up to 2 seconds
|
||||||
Thread.sleep(700);
|
long initial = System.currentTimeMillis();
|
||||||
|
while (System.currentTimeMillis() - initial < 2000 &&
|
||||||
|
(entriesSent != entriesReceived)) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
fail("An error occured sending the message with the roster");
|
fail("An error occured sending the message with the roster");
|
||||||
|
|
|
@ -1678,7 +1678,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
// User2 leaves the room
|
// User2 leaves the room
|
||||||
muc2.leave();
|
muc2.leave();
|
||||||
|
|
||||||
Thread.sleep(150);
|
Thread.sleep(250);
|
||||||
// Check that ParticipantStatusListener is working OK
|
// Check that ParticipantStatusListener is working OK
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"User1 didn't receive the event of User2 joining the room",
|
"User1 didn't receive the event of User2 joining the room",
|
||||||
|
|
Loading…
Reference in a new issue