mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-30 02:02:06 +01:00
Fix offline presence info, including test case (SMACK-219).
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@8275 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
bdc61a2db2
commit
466b7e2d08
2 changed files with 16 additions and 9 deletions
|
@ -696,10 +696,9 @@ public class Roster {
|
||||||
// Otherwise, this is a normal offline presence.
|
// Otherwise, this is a normal offline presence.
|
||||||
else if (presenceMap.get(key) != null) {
|
else if (presenceMap.get(key) != null) {
|
||||||
Map<String, Presence> userPresences = presenceMap.get(key);
|
Map<String, Presence> userPresences = presenceMap.get(key);
|
||||||
userPresences.remove(StringUtils.parseResource(from));
|
// Store the offline presence, as it may include extra information
|
||||||
if (userPresences.isEmpty()) {
|
// such as the user being on vacation.
|
||||||
presenceMap.remove(key);
|
userPresences.put(StringUtils.parseResource(from), presence);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// If the user is in the roster, fire an event.
|
// If the user is in the roster, fire an event.
|
||||||
for (RosterEntry entry : entries) {
|
for (RosterEntry entry : entries) {
|
||||||
|
|
|
@ -229,6 +229,8 @@ public class PresenceTest extends SmackTestCase {
|
||||||
/**
|
/**
|
||||||
* User1 logs in, then sets offline presence information (presence with status text). User2
|
* User1 logs in, then sets offline presence information (presence with status text). User2
|
||||||
* logs in and checks to see if offline presence is returned.
|
* logs in and checks to see if offline presence is returned.
|
||||||
|
*
|
||||||
|
* @throws Exception if an exception occurs.
|
||||||
*/
|
*/
|
||||||
public void testOfflineStatusPresence() throws Exception {
|
public void testOfflineStatusPresence() throws Exception {
|
||||||
// Add a new roster entry for other user.
|
// Add a new roster entry for other user.
|
||||||
|
@ -242,14 +244,20 @@ public class PresenceTest extends SmackTestCase {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sign out of conn0.
|
|
||||||
getConnection(0).disconnect();
|
|
||||||
|
|
||||||
// Sign out of conn1 with status
|
// Sign out of conn1 with status
|
||||||
Presence offlinePresence = new Presence(Presence.Type.unavailable);
|
Presence offlinePresence = new Presence(Presence.Type.unavailable);
|
||||||
offlinePresence.setStatus("Offline test");
|
offlinePresence.setStatus("Offline test");
|
||||||
getConnection(1).disconnect(offlinePresence);
|
getConnection(1).disconnect(offlinePresence);
|
||||||
|
|
||||||
|
// Wait 500 ms
|
||||||
|
Thread.sleep(500);
|
||||||
|
Presence presence = getConnection(0).getRoster().getPresence(getBareJID(1));
|
||||||
|
assertTrue("Offline presence status not received.",
|
||||||
|
"Offline test".equals(presence.getStatus()));
|
||||||
|
|
||||||
|
// Sign out of conn0.
|
||||||
|
getConnection(0).disconnect();
|
||||||
|
|
||||||
// See if conneciton 0 can get offline status.
|
// See if conneciton 0 can get offline status.
|
||||||
XMPPConnection con0 = getConnection(0);
|
XMPPConnection con0 = getConnection(0);
|
||||||
con0.connect();
|
con0.connect();
|
||||||
|
@ -257,8 +265,8 @@ public class PresenceTest extends SmackTestCase {
|
||||||
|
|
||||||
// Wait 500 ms
|
// Wait 500 ms
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
Presence presence = con0.getRoster().getPresence(getBareJID(1));
|
presence = con0.getRoster().getPresence(getBareJID(1));
|
||||||
assertTrue("Offline presence status not received.",
|
assertTrue("Offline presence status not received after logout.",
|
||||||
"Offline test".equals(presence.getStatus()));
|
"Offline test".equals(presence.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue