mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 22:12:05 +01:00
Modified priority testing to include more cases.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2465 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
941b9e752f
commit
08f3b3dcba
1 changed files with 48 additions and 0 deletions
|
@ -62,6 +62,7 @@ public class PresencePriorityTest extends SmackTestCase {
|
||||||
conn.sendPacket(new Presence(Presence.Type.AVAILABLE, null, 1,
|
conn.sendPacket(new Presence(Presence.Type.AVAILABLE, null, 1,
|
||||||
Presence.Mode.AVAILABLE));
|
Presence.Mode.AVAILABLE));
|
||||||
|
|
||||||
|
Thread.sleep(150);
|
||||||
// Test delivery of message to the presence with highest priority
|
// Test delivery of message to the presence with highest priority
|
||||||
chat0.sendMessage("Hello");
|
chat0.sendMessage("Hello");
|
||||||
assertNotNull("Resource with highest priority didn't receive the message",
|
assertNotNull("Resource with highest priority didn't receive the message",
|
||||||
|
@ -69,6 +70,48 @@ public class PresencePriorityTest extends SmackTestCase {
|
||||||
assertNull("Resource with lowest priority received the message",
|
assertNull("Resource with lowest priority received the message",
|
||||||
chat2.nextMessage(1000));
|
chat2.nextMessage(1000));
|
||||||
|
|
||||||
|
// User_1 closes his connection
|
||||||
|
chat2 = null;
|
||||||
|
conn.close();
|
||||||
|
Thread.sleep(150);
|
||||||
|
|
||||||
|
// Test delivery of message to the unique presence of the user_1
|
||||||
|
chat0.sendMessage("Hello");
|
||||||
|
assertNotNull("Resource with highest priority didn't receive the message",
|
||||||
|
chat1.nextMessage(2000));
|
||||||
|
|
||||||
|
getConnection(1).sendPacket(new Presence(Presence.Type.AVAILABLE, null, 2,
|
||||||
|
Presence.Mode.AVAILABLE));
|
||||||
|
|
||||||
|
// User_1 will log in again using another resource
|
||||||
|
conn = new XMPPConnection(getHost(), getPort());
|
||||||
|
conn.login(getUsername(1), getUsername(1), "OtherPlace");
|
||||||
|
conn.sendPacket(new Presence(Presence.Type.AVAILABLE, null, 1,
|
||||||
|
Presence.Mode.AVAILABLE));
|
||||||
|
chat2 = new Chat(conn, getBareJID(0));
|
||||||
|
|
||||||
|
Thread.sleep(150);
|
||||||
|
// Test delivery of message to the presence with highest priority
|
||||||
|
chat0.sendMessage("Hello");
|
||||||
|
assertNotNull("Resource with highest priority didn't receive the message",
|
||||||
|
chat1.nextMessage(2000));
|
||||||
|
assertNull("Resource with lowest priority received the message",
|
||||||
|
chat2.nextMessage(1000));
|
||||||
|
|
||||||
|
// Invert the presence priorities of User_1
|
||||||
|
getConnection(1).sendPacket(new Presence(Presence.Type.AVAILABLE, null, 1,
|
||||||
|
Presence.Mode.AVAILABLE));
|
||||||
|
conn.sendPacket(new Presence(Presence.Type.AVAILABLE, null, 2,
|
||||||
|
Presence.Mode.AVAILABLE));
|
||||||
|
|
||||||
|
Thread.sleep(150);
|
||||||
|
// Test delivery of message to the presence with highest priority
|
||||||
|
chat0.sendMessage("Hello");
|
||||||
|
assertNotNull("Resource with highest priority didn't receive the message",
|
||||||
|
chat2.nextMessage(2000));
|
||||||
|
assertNull("Resource with lowest priority received the message",
|
||||||
|
chat1.nextMessage(1000));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -86,4 +129,9 @@ public class PresencePriorityTest extends SmackTestCase {
|
||||||
protected int getMaxConnections() {
|
protected int getMaxConnections() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
XMPPConnection.DEBUG_ENABLED = false;
|
||||||
|
super.setUp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue