* This tests that getChildNode works. We'll add some nodes and make sure they are found correctly. We'll also add a
* duplicate named node. It should never be returned because getChildNode only finds the first one. Lastly, we'll
* call getChildNode for a node that doesn't exist. It shouldn't be returned.
*/
public void testGetChildNode() {
SettingsNode childNode1 = rootNode.addChild(SAMPLE_NAME_1);
SettingsNode childNode2 = rootNode.addChild(SAMPLE_NAME_2);
SettingsNode childNode3 = rootNode.addChild(SAMPLE_NAME_3);
SettingsNode childNode4 = rootNode.addChild(
SAMPLE_NAME_2); //this is a duplicate and should never be found via getChildNode.
assertNotNull(Dom4JUtility.getChild(rootElement, DOM4JSettingsNode.TAG_NAME, DOM4JSettingsNode.NAME_ATTRIBUTE,
SAMPLE_NAME_1));
assertNotNull(Dom4JUtility.getChild(rootElement, DOM4JSettingsNode.TAG_NAME, DOM4JSettingsNode.NAME_ATTRIBUTE,
SAMPLE_NAME_2));
assertNotNull(Dom4JUtility.getChild(rootElement, DOM4JSettingsNode.TAG_NAME, DOM4JSettingsNode.NAME_ATTRIBUTE,
SAMPLE_NAME_3));
assertNotNull(rootNode.getChildNode(SAMPLE_NAME_1));
assertNotNull(rootNode.getChildNode(SAMPLE_NAME_2));
assertNotNull(rootNode.getChildNode(SAMPLE_NAME_3));
SettingsNode foundNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
assertEquals(foundNode1, childNode1);
SettingsNode foundNode2 = rootNode.getChildNode(SAMPLE_NAME_2);
assertEquals(foundNode2, childNode2);
SettingsNode foundNode3 = rootNode.getChildNode(SAMPLE_NAME_3);
assertEquals(foundNode3, childNode3);
//look for the duplicated
SettingsNode foundNode2B = rootNode.getChildNode(SAMPLE_NAME_2);
assertEquals(foundNode2B, childNode2); //should still be childNode2.
//this one shouldn't be found.
SettingsNode foundNode4 = rootNode.getChildNode("notpresent");
assertNull(foundNode4);
}