コード例 #1
0
  @Test
  public void testCreate() throws Exception {
    GroupExtension ext =
        new GroupExtension(
            "mad-group",
            "david@localhost",
            GroupExtension.Type.CREATE,
            "Mad group",
            Collections.<Member>emptyList());
    ext.addMember("alpha@localhost");
    ext.addMember("beta@localhost");

    GroupExtension parsed = parse(ext.toXML());
    assertNotNull(parsed);
    assertEquals("mad-group", parsed.getID());
    assertEquals("david@localhost", parsed.getOwner());
    assertEquals("Mad group", parsed.getSubject());
    assertNotNull(ext.getMembers());
    assertEquals(2, ext.getMembers().size());

    Member m;

    m = ext.getMembers().get(0);
    assertNotNull(m);
    assertEquals("alpha@localhost", m.jid);
    assertEquals(Member.Operation.ADD, m.operation);

    m = ext.getMembers().get(1);
    assertNotNull(m);
    assertEquals("beta@localhost", m.jid);
    assertEquals(Member.Operation.ADD, m.operation);
  }
コード例 #2
0
  @Test
  public void testSimple() throws Exception {
    GroupExtension ext = new GroupExtension("mad-group", "david@localhost");

    GroupExtension parsed = parse(ext.toXML());
    assertNotNull(parsed);
    assertEquals("mad-group", parsed.getID());
    assertEquals("david@localhost", parsed.getOwner());
  }
コード例 #3
0
  @Test
  public void testPart() throws Exception {
    GroupExtension ext =
        new GroupExtension("mad-group", "david@localhost", GroupExtension.Type.PART);

    GroupExtension parsed = parse(ext.toXML());
    assertNotNull(parsed);
    assertEquals("mad-group", parsed.getID());
    assertEquals("david@localhost", parsed.getOwner());
    assertEquals(Collections.emptyList(), ext.getMembers());
  }
コード例 #4
0
  @Test
  public void testRemove() throws Exception {
    GroupExtension ext =
        new GroupExtension("mad-group", "david@localhost", GroupExtension.Type.SET);
    ext.removeMember("alpha@localhost");

    GroupExtension parsed = parse(ext.toXML());
    assertNotNull(parsed);
    assertEquals("mad-group", parsed.getID());
    assertEquals("david@localhost", parsed.getOwner());
    assertNotNull(ext.getMembers());
    assertEquals(1, ext.getMembers().size());

    Member m;

    m = ext.getMembers().get(0);
    assertNotNull(m);
    assertEquals("alpha@localhost", m.jid);
    assertEquals(Member.Operation.REMOVE, m.operation);
  }