Hi
In this test this assertion fails:
assertEquals(“Offline presence status not received.”, “Offline test”, presence.getStatus());
As the status is null.
The messages are:
Presence sent by test2:
Offline test
Presence received by test1:
Offline test
Test 1 is the user for connection 0, test2 the user for connection 1.
So, whilst the messages are correctly sent and received, and there is a presence, the status value of the presence is null.
As far as I can tell this is just wrong, and not obviously timing related.
Regards
Nathan
public void testOfflineStatusPresence() throws Exception {
// Add a new roster entry for other user.
Roster roster = getConnection(0).getRoster();
roster.createEntry(getBareJID(1), “gato1”, null);
// Wait up to 2 seconds
long initial = System.currentTimeMillis();
while (System.currentTimeMillis() - initial < 2000 && (
roster.getPresence(getBareJID(1)).getType().equals(Presence.Type.unavailable))) {
Thread.sleep(100);
}
// Sign out of conn1 with status
Presence offlinePresence = new Presence(Presence.Type.unavailable);
offlinePresence.setStatus(“Offline test”);
getConnection(1).disconnect(offlinePresence);
// Wait 500 ms
Thread.sleep(500);
Presence presence = getConnection(0).getRoster().getPresence(getBareJID(1));
assertEquals(“Offline presence status not received.”, “Offline test”, presence.getStatus());
// Sign out of conn0.
getConnection(0).disconnect();
// See if conneciton 0 can get offline status.
XMPPConnection con0 = getConnection(0);
con0.connect();
con0.login(getUsername(0), getUsername(0));
// Wait 500 ms
Thread.sleep(500);
presence = con0.getRoster().getPresence(getBareJID(1));
assertTrue(“Offline presence status not received after logout.”,
“Offline test”.equals(presence.getStatus()));
}