コード例 #1
0
  @Test
  public void canReplaceAChildElement() {
    SpinXmlElement child = XML("<child/>");
    SpinXmlElement date = element.childElement("date");
    assertThat(date).isNotNull();

    element.replaceChild(date, child);

    assertThat(element.childElement(null, "child")).isNotNull();
    try {
      element.childElement("date");
    } catch (Exception e) {
      assertThat(e).isInstanceOf(SpinXmlElementException.class);
    }
  }
コード例 #2
0
 @Test(expected = SpinXmlElementException.class)
 public void cannotReplaceANonChildElement() {
   SpinXmlElement child = XML("<child/>");
   SpinXmlElement nonChild = XML("<child/>");
   element.replaceChild(nonChild, child);
 }
コード例 #3
0
 @Test(expected = IllegalArgumentException.class)
 public void cannotReplaceByANullChildElement() {
   SpinXmlElement date = element.childElement("date");
   element.replaceChild(date, null);
 }
コード例 #4
0
 @Test(expected = IllegalArgumentException.class)
 public void cannotReplaceANullChildElement() {
   SpinXmlElement child = XML("<child/>");
   element.replaceChild(null, child);
 }