Package com.calclab.emite.xep.muc

Examples of com.calclab.emite.xep.muc.Occupant


public class RoomOccupantTest {

  @Test
  public void shouldAnswerUnknownStatusWhenNotValid() {
    final Occupant occupant = new Occupant(uri("user@domain"), uri("room@domain/user"), "not valid affiliation", "not valid role", Show.unknown, "message");
    assertEquals(Occupant.Affiliation.none, occupant.getAffiliation());
    assertEquals(Occupant.Role.unknown, occupant.getRole());
    assertEquals(Show.unknown, occupant.getShow());
  }
View Full Code Here


  @Test
  public void shouldAddOccupantAndFireListeners() {
    final OccupantChangedTestHandler handler = new OccupantChangedTestHandler();
    room.addOccupantChangedHandler(handler);
    final XmppURI occupantUri = uri("room@domain/user");
    final Occupant occupant = room.setOccupantPresence(userURI, occupantUri, "aff", "role", Show.unknown, null);
    assertTrue(handler.isCalledOnce());
    final Occupant result = room.getOccupantByOccupantUri(occupantUri);
    assertEquals(occupant, result);
  }
View Full Code Here

  @Test
  public void shouldUpdateOccupantAndFireListeners() {
    final OccupantChangedTestHandler handler = new OccupantChangedTestHandler("modified");
    room.addOccupantChangedHandler(handler);
    final XmppURI occupantUri = uri("room@domain/name");
    final Occupant occupant = room.setOccupantPresence(userURI, occupantUri, "owner", "participant", Show.notSpecified, null);
    final Occupant occupant2 = room.setOccupantPresence(userURI, occupantUri, "admin", "moderator", Show.notSpecified, null);
    assertEquals(1, handler.getCalledTimes());
    assertSame(occupant, occupant2);
  }
View Full Code Here

    final RoomChat room = manager.open(uri("room1@domain/nick"));
    session.receives("<presence to='user@domain/resource' from='room1@domain/otherUser2'>" + "<priority>0</priority>"
        + "<x xmlns='http://jabber.org/protocol/muc#user'>" + "<item jid='otheruserjid@domain/otherresoruce' affiliation='none' "
        + "role='participant'/></x>" + "<x xmlns='vcard-temp:x:update'><photo>af70fe6519d6a27a910c427c3bc551dcd36073e7</photo></x>" + "</presence>");
    assertEquals(1, room.getOccupantsCount());
    final Occupant occupant = room.getOccupantByOccupantUri(uri("room1@domain/otherUser2"));
    assertNotNull(occupant);
    assertEquals(Affiliation.none, occupant.getAffiliation());
    assertEquals(Role.participant, occupant.getRole());
  }
View Full Code Here

    final RoomChat room = manager.open(uri("room1@domain/nick"));

    session.receives("<presence to='user@domain/resource' xmlns='jabber:client' from='room1@domain/otherUser'>"
        + "<x xmlns='http://jabber.org/protocol/muc#user'>" + "<item role='moderator' affiliation='owner' jid='otherUser@domain' /></x></presence>");
    assertEquals(1, room.getOccupantsCount());
    Occupant user = room.getOccupantByOccupantUri(uri("room1@domain/otherUser"));
    assertNotNull(user);
    assertEquals(Affiliation.owner, user.getAffiliation());
    assertEquals(Role.moderator, user.getRole());

    session.receives("<presence to='user@domain/resource' xmlns='jabber:client' from='room1@domain/otherUser'>"
        + "<x xmlns='http://jabber.org/protocol/muc#user'>" + "<item role='participant' affiliation='member' /></x></presence>");
    assertEquals(1, room.getOccupantsCount());
    user = room.getOccupantByOccupantUri(uri("room1@domain/otherUser"));
    assertNotNull(user);
    assertEquals(Affiliation.member, user.getAffiliation());
    assertEquals(Role.participant, user.getRole());

    session.receives("<presence to='user@domain/res1' type='unavailable' " + "xmlns='jabber:client' from='room1@domain/otherUser'>"
        + "<status>custom message</status><x xmlns='http://jabber.org/protocol/muc#user'>" + "<item role='none' affiliation='member' /></x></presence>");
    assertEquals(0, room.getOccupantsCount());
View Full Code Here

TOP

Related Classes of com.calclab.emite.xep.muc.Occupant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.