Package com.calclab.emite.xtesting.handlers

Examples of com.calclab.emite.xtesting.handlers.RosterItemChangedTestHandler


        + "<item jid='friend@domain' name='MyFriend'><group>Group1</group><group>Group2</group>" + "</item></query></iq>");
  }

  @Test
  public void addRosterStep2_shouldAddItemFireListenerAndSendResponse() {
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler("added");
    roster.addRosterItemChangedHandler(handler);

    session.receives("<iq type='set' from='someone@domain' id='theId'><query xmlns='jabber:iq:roster'>"
        + "<item jid='friend@domain' name='MyFriend'><group>Group1</group><group>Group2</group>" + "</item></query></iq>");
    assertTrue(handler.isCalledOnce());
    assertEquals(1, roster.getItems().size());
    final RosterItem item = asList(roster.getItems()).get(0);
    assertEquals("friend@domain", item.getJID().toString());
    assertEquals("MyFriend", item.getName());
    assertEquals(2, item.getGroups().size());
View Full Code Here


  }

  @Test
  public void shouldHandleInitialPresence() {
    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='MyFriend' /></query></iq>");
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    roster.addRosterItemChangedHandler(handler);
    session.receives("<presence from='friend@domain' />");
    final RosterItem item = roster.getItemByJID(uri("friend@domain"));
    assertEquals(item, handler.getLastRosterItem());
    assertTrue(item.isAvailable());
  }
View Full Code Here

  @Test
  public void shouldHandlePresenceInformationOnRosterItems() {
    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='MyFriend' /></query></iq>");

    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    roster.addRosterItemChangedHandler(handler);
    session.receives("<presence from='friend@domain'>" + "<show>dnd</show><status>message</status><priority>3</priority></presence>");
    final RosterItem item = roster.getItemByJID(uri("friend@domain"));
    assertEquals(Presence.Show.dnd, item.getShow());
    assertEquals("message", item.getStatus());
    assertEquals(item, handler.getLastRosterItem());
  }
View Full Code Here

  }

  @Test
  public void shouldHandleUnavailablePresence() {
    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='MyFriend' /></query></iq>");
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    roster.addRosterItemChangedHandler(handler);
    session.receives("<presence type='unavailable' from='friend@domain' />");
    final RosterItem item = roster.getItemByJID(uri("friend@domain"));
    assertEquals(item, handler.getLastRosterItem());
    assertFalse(item.isAvailable());

  }
View Full Code Here

  }

  @Test
  public void shouldRemoveItems() {
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler("removed");
    roster.addRosterItemChangedHandler(handler);

    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>"
        + "<item jid='friend@domain' name='MyFriend'><group>Group1</group><group>Group2</group>" + "</item></query></iq>");
    assertEquals(1, roster.getItems().size());
    assertEquals(3, roster.getGroupNames().size());
    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>"
        + "<item jid='friend@domain' subscription='remove' name='MyFriend'><group>Group1</group>" + "</item></query></iq>");
    assertTrue(handler.isCalledOnce());
    assertEquals(0, roster.getItems().size());
    assertEquals(1, roster.getGroupNames().size());
  }
View Full Code Here

    // item.getPresence().getType());
  }

  @Test
  public void shouldUpdateItem() {
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    roster.addRosterItemChangedHandler(handler);

    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='Friend1'><group>GG1</group><group>GG2</group>"
        + "</item></query></iq>");
    session.receives("<iq type='set'><query xmlns='jabber:iq:roster'>" + "<item jid='friend@domain' name='Friend2'><group>HH1</group><group>HH2</group>"
        + "</item></query></iq>");
    assertEquals("RosterItemChangedHandler should be called twice", 2, handler.getCalledTimes());
    assertEquals(1, roster.getItems().size());
    assertEquals(3, roster.getGroupNames().size());
    assertTrue(roster.getGroupNames().contains("HH1"));
    assertTrue(roster.getGroupNames().contains("HH2"));
  }
View Full Code Here

  }

  @Test
  public void shouldChangeItemPresenceAndFireEvent() {
    setRosterItems(session, newItem("other@domain"));
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    roster.addRosterItemChangedHandler(handler);
    session.receives("<presence from='other@domain'>" + "<show>dnd</show><status>message</status><priority>3</priority></presence>");
    final RosterItem item = roster.getItemByJID(uri("other@domain"));
    assertEquals(Presence.Show.dnd, item.getShow());
    assertEquals("message", item.getStatus());
    assertTrue(handler.isCalledOnce());
  }
View Full Code Here

  public void shouldFireChangedItemEventsInGroups() {
    final RosterItem item = newItem("other@domain");
    item.addToGroup("simple");
    setRosterItems(session, item);
    final RosterGroup group = roster.getRosterGroup("simple");
    final RosterItemChangedTestHandler handler = new RosterItemChangedTestHandler();
    group.addRosterItemChangedHandler(handler);
    assertNotNull(group);
    session.receives("<presence from='other@domain'>" + "<show>dnd</show><status>message</status><priority>3</priority></presence>");
    assertTrue(handler.hasEvent());
  }
View Full Code Here

TOP

Related Classes of com.calclab.emite.xtesting.handlers.RosterItemChangedTestHandler

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.