SessionStateHolder sessionStateHolder = new SessionStateHolder();
sessionStateHolder.setState(SessionState.AUTHENTICATED);
// pres 1
XMPPCoreStanza initialPresence1 = sendInitialPresence(sessionStateHolder, initiatingUser);
PresenceStanza presenceStanza1 = getCache().get(initiatingUser.getEntityFQ());
assertSame(initialPresence1, presenceStanza1);
assertSame(initialPresence1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));
// pres 2, same user
XMPPCoreStanza initialPresence2 = sendInitialPresence(sessionStateHolder, anotherInterestedUser);
PresenceStanza presenceStanza2 = getCache().get(anotherInterestedUser.getEntityFQ());
assertSame(initialPresence2, presenceStanza2);
assertSame(initialPresence2, getCache().getForBareJID(anotherInterestedUser.getEntity().getBareJID()));
// re-retrieve the pres 1, still there
PresenceStanza presenceStanza1_again = getCache().get(initiatingUser.getEntityFQ());
assertSame(initialPresence1, presenceStanza1_again);
assertSame(initialPresence2, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));
// replace pres 1
XMPPCoreStanza initialPresence1_1 = sendInitialPresence(sessionStateHolder, initiatingUser);
PresenceStanza presenceStanza1_1 = getCache().get(initiatingUser.getEntityFQ());
assertSame(initialPresence1_1, presenceStanza1_1);
assertSame(initialPresence1_1, getCache().getForBareJID(initiatingUser.getEntity().getBareJID()));
}