コード例 #1
0
  @Test(expected = IllegalArgumentException.class)
  public void cannotRemoveANullChildElement() {
    SpinXmlElement child = XML("<child/>");
    element.append(child);

    element.remove(child, null);
  }
コード例 #2
0
  @Test(expected = SpinXmlElementException.class)
  public void cannotRemoveNonChildElement() {
    SpinXmlElement child1 = XML("<child/>");
    SpinXmlElement child2 = XML("<child/>");

    element.append(child1);

    element.remove(child1, child2);
  }
コード例 #3
0
  @Test
  public void canRemoveAChildElement() {
    SpinXmlElement child = XML("<child/>");
    element.append(child);

    assertThat(element.childElement(null, "child")).isNotNull();

    element.remove(child);

    try {
      assertThat(element.childElement(null, "child"));
      fail("Child element should be removed");
    } catch (Exception e) {
      assertThat(e).isInstanceOf(SpinXmlElementException.class);
    }
  }
コード例 #4
0
  @Test
  public void canRemoveChildElementCollection() {
    SpinXmlElement child1 = XML("<child/>");
    SpinXmlElement child2 = XML("<child/>");
    SpinXmlElement child3 = XML("<child/>");
    element.append(child1, child2, child3);

    assertThat(element.childElements(null, "child")).hasSize(3);

    element.remove(element.childElements(null, "child"));

    try {
      assertThat(element.childElements(null, "child"));
      fail("Child element should be removed");
    } catch (Exception e) {
      assertThat(e).isInstanceOf(SpinXmlElementException.class);
    }
  }
コード例 #5
0
 @Test(expected = IllegalArgumentException.class)
 public void cannotRemoveNullChildElements() {
   element.remove((SpinXmlElement[]) null);
 }