public void testChildrenNamed() {
   Node element2Node = XMLTools.child(this.rootNode, "element-2");
   Node[] children = XMLTools.children(element2Node, "element-2.0");
   assertEquals(3, children.length);
   for (int i = 0; i < children.length; i++) {
     assertEquals("element-2.0", children[i].getNodeName());
   }
 }
 public void testChildTextContentDefaultValue() {
   assertEquals(
       "element 3 contents",
       XMLTools.childTextContent(this.rootNode, "element-3", "default value 3"));
   assertEquals(
       "default value 4",
       XMLTools.childTextContent(this.rootNode, "element-4", "default value 4"));
 }
  public void testChildBooleanContentDefaultValue() {
    Node node = XMLTools.child(this.rootNode, "element-1");
    assertTrue(XMLTools.childBooleanContent(node, "element-1-boolean-true-1", false));
    assertTrue(XMLTools.childBooleanContent(node, "element-1-boolean-true-2", false));
    assertTrue(XMLTools.childBooleanContent(node, "element-1-boolean-true-3", false));
    assertFalse(XMLTools.childBooleanContent(node, "element-1-boolean-true-bogus", false));

    assertFalse(XMLTools.childBooleanContent(node, "element-1-boolean-false-1", true));
    assertFalse(XMLTools.childBooleanContent(node, "element-1-boolean-false-2", true));
    assertFalse(XMLTools.childBooleanContent(node, "element-1-boolean-false-3", true));
    assertTrue(XMLTools.childBooleanContent(node, "element-1-boolean-false-bogus", true));
  }
 public void testChildren() {
   Node[] children = XMLTools.children(this.rootNode);
   assertEquals(4, children.length);
   for (int i = 1; i < 4; i++) {
     assertEquals("element-" + i, children[i].getNodeName());
   }
 }
  public void testChildBooleanContent() {
    Node node = XMLTools.child(this.rootNode, "element-1");
    assertTrue(XMLTools.childBooleanContent(node, "element-1-boolean-true-1"));
    assertTrue(XMLTools.childBooleanContent(node, "element-1-boolean-true-2"));
    assertTrue(XMLTools.childBooleanContent(node, "element-1-boolean-true-3"));

    assertFalse(XMLTools.childBooleanContent(node, "element-1-boolean-false-1"));
    assertFalse(XMLTools.childBooleanContent(node, "element-1-boolean-false-2"));
    assertFalse(XMLTools.childBooleanContent(node, "element-1-boolean-false-3"));
  }
  public void testTextContent() {
    Node node = XMLTools.child(this.rootNode, "element-0");
    Node childNode = XMLTools.child(node, "element-0-text-1");
    assertEquals("some text", XMLTools.textContent(childNode));

    childNode = XMLTools.child(node, "element-0-text-2");
    assertEquals("", XMLTools.textContent(childNode));

    childNode = XMLTools.child(node, "element-0-text-3");
    assertEquals("", XMLTools.textContent(childNode));

    childNode = XMLTools.child(node, "element-0-non-text");
    boolean exCaught = false;
    try {
      String text = XMLTools.textContent(childNode);
      text = text.toString();
    } catch (IllegalArgumentException ex) {
      exCaught = true;
    }
    assertTrue(exCaught);
  }
 public void testChild() {
   assertEquals("element-1", XMLTools.child(this.rootNode, "element-1").getNodeName());
   assertEquals("element-3", XMLTools.child(this.rootNode, "element-3").getNodeName());
   assertEquals(null, XMLTools.child(this.rootNode, "element-1x"));
 }
 private Document buildTestDocument() {
   return XMLTools.parse(new StringReader(this.buildTestDocumentString()));
 }
 protected void setUp() throws Exception {
   super.setUp();
   this.testDocument = this.buildTestDocument();
   this.rootNode = XMLTools.child(this.testDocument, "root-element");
 }
 public void testChildIntContentDefaultValue() {
   Node node = XMLTools.child(this.rootNode, "element-1");
   assertEquals(42, XMLTools.childIntContent(node, "element-1-int", 99));
   assertEquals(99, XMLTools.childIntContent(node, "element-1-int-x", 99));
 }
 public void testChildIntContent() {
   Node node = XMLTools.child(this.rootNode, "element-1");
   assertEquals(42, XMLTools.childIntContent(node, "element-1-int"));
 }
 public void testChildTextContent() {
   assertEquals("element 3 contents", XMLTools.childTextContent(this.rootNode, "element-3"));
 }