00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 package org.w3c.domts.level1.core;
00021
00022 import org.w3c.dom.*;
00023 import org.w3c.dom.html.*;
00024 import org.w3c.dom.events.*;
00025 import org.w3c.domts.*;
00026 import javax.xml.parsers.*;
00027 import java.util.*;
00028
00029
00030
00046 public class nodereplacechildnewchildexists extends DOMTestCase {
00047
00048 public nodereplacechildnewchildexists(DOMTestDocumentBuilderFactory factory)
00049 {
00050 super(factory);
00051
00052 }
00053
00054 public void runTest() throws java.lang.Throwable {
00055 Document doc;
00056 NodeList elementList;
00057 Node employeeNode;
00058 NodeList childList;
00059 Node oldChild = null;
00060
00061 Node newChild = null;
00062
00063 Node child;
00064 String childName;
00065 Node childNode;
00066 List actual = new ArrayList();
00067
00068 List expected = new ArrayList();
00069
00070 List expectedWithoutWhitespace = new ArrayList();
00071 expectedWithoutWhitespace.add("name");
00072 expectedWithoutWhitespace.add("position");
00073 expectedWithoutWhitespace.add("salary");
00074 expectedWithoutWhitespace.add("gender");
00075 expectedWithoutWhitespace.add("employeeId");
00076
00077 List expectedWithWhitespace = new ArrayList();
00078 expectedWithWhitespace.add("#text");
00079 expectedWithWhitespace.add("#text");
00080 expectedWithWhitespace.add("name");
00081 expectedWithWhitespace.add("#text");
00082 expectedWithWhitespace.add("position");
00083 expectedWithWhitespace.add("#text");
00084 expectedWithWhitespace.add("salary");
00085 expectedWithWhitespace.add("#text");
00086 expectedWithWhitespace.add("gender");
00087 expectedWithWhitespace.add("#text");
00088 expectedWithWhitespace.add("employeeId");
00089 expectedWithWhitespace.add("#text");
00090
00091 Node replacedChild;
00092 doc = load("staff");
00093 elementList = doc.getElementsByTagName("employee");
00094 employeeNode = elementList.item(1);
00095 childList = employeeNode.getChildNodes();
00096
00097 if(
00098 !isIgnoringElementContentWhitespace()
00099 ) {
00100 newChild = childList.item(1);
00101 oldChild = childList.item(11);
00102 expected = expectedWithWhitespace;
00103
00104 }
00105
00106 else {
00107 newChild = childList.item(0);
00108 oldChild = childList.item(5);
00109 expected = expectedWithoutWhitespace;
00110
00111 }
00112 replacedChild = employeeNode.replaceChild(newChild,oldChild);
00113 assertSame("return_value_same",oldChild,replacedChild);
00114 for(int _index = 0; _index < childList.getLength();_index++) {
00115 childNode = ( Node ) childList.item(_index);
00116 childName = childNode.getNodeName();
00117 actual.add(childName);
00118
00119 }
00120 assertEquals("childNames",expected,actual);
00121
00122 }
00123 public String getTargetURI() {
00124 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnewchildexists";
00125 }
00126 public static void main(String[] args) {
00127 DOMTestCase.doMain(nodereplacechildnewchildexists.class,args);
00128 }
00129 }