// now, let user 1 enter room
enterRoom(OCCUPANT1_JID, ROOM1_JID_WITH_NICK);
// verify stanzas to existing occupants on the new user
Stanza user1JoinedStanza = occupant2Queue.getNext();
// should be from room + nick name
assertEquals(ROOM1_JID.getFullQualifiedName() + "/nick", user1JoinedStanza.getFrom().getFullQualifiedName());
// should be to the existing user
assertEquals(OCCUPANT2_JID, user1JoinedStanza.getTo());
XMLElement xElement = user1JoinedStanza.getSingleInnerElementsNamed("x");
assertEquals(NamespaceURIs.XEP0045_MUC_USER, xElement.getNamespaceURI());
// since this room is non-anonymous, x must contain an item element with the users full JID
XMLElement itemElement = xElement.getSingleInnerElementsNamed("item");
assertEquals(OCCUPANT1_JID.getFullQualifiedName(), itemElement.getAttributeValue("jid"));
assertEquals("none", itemElement.getAttributeValue("affiliation"));
assertEquals("participant", itemElement.getAttributeValue("role"));
// verify stanzas to the new user on all existing users, including himself with status=110 element
// own presence must be sent last
// assert the stanza from the already existing user
Stanza stanza = occupant1Queue.getNext();
assertNotNull(stanza);
assertEquals(ROOM1_JID.getFullQualifiedName() + "/Some nick", stanza.getFrom().getFullQualifiedName());
assertEquals(OCCUPANT1_JID, stanza.getTo());
// assert stanza from the joining user, must have extra status=110 element
stanza = occupant1Queue.getNext();
assertNotNull(stanza);
assertEquals(ROOM1_JID_WITH_NICK, stanza.getFrom());
assertEquals(OCCUPANT1_JID, stanza.getTo());
List<XMLElement> statusElements = stanza.getFirstInnerElement().getInnerElementsNamed("status");
assertEquals(2, statusElements.size());
assertEquals("100", statusElements.get(0).getAttributeValue("code"));
assertEquals("110", statusElements.get(1).getAttributeValue("code"));
}