1
2/*
3This Java source file was generated by test-to-java.xsl
4and is a derived work from the source document.
5The source document contained the following notice:
6
7
8Copyright (c) 2001-2003 World Wide Web Consortium,
9(Massachusetts Institute of Technology, Institut National de
10Recherche en Informatique et en Automatique, Keio University). All
11Rights Reserved. This program is distributed under the W3C's Software
12Intellectual Property License. This program is distributed in the
13hope that it will be useful, but WITHOUT ANY WARRANTY; without even
14the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15PURPOSE.
16See W3C License http://www.w3.org/Consortium/Legal/ for more details.
17
18*/
19
20package org.w3c.domts.level1.core;
21
22import org.w3c.dom.*;
23
24
25import org.w3c.domts.DOMTestCase;
26import org.w3c.domts.DOMTestDocumentBuilderFactory;
27
28
29
30/**
31 *     If the "newChild" is already in the tree, it is first
32 *     removed before the new one is appended.
33 *
34 *     Retrieve the "em" second employee and
35 *     append the first child to the end of the list.   After
36 *     the "appendChild(newChild)" method is invoked the first
37 *     child should be the one that was second and the last
38 *     child should be the one that was first.
39* @author Curt Arnold
40* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107</a>
41* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=246">http://www.w3.org/Bugs/Public/show_bug.cgi?id=246</a>
42*/
43public final class hc_nodeappendchildchildexists extends DOMTestCase {
44
45   /**
46    * Constructor.
47    * @param factory document factory, may not be null
48    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
49    */
50   public hc_nodeappendchildchildexists(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
51      super(factory);
52
53    //
54    //   check if loaded documents are supported for content type
55    //
56    String contentType = getContentType();
57    preload(contentType, "hc_staff", true);
58    }
59
60   /**
61    * Runs the test case.
62    * @throws Throwable Any uncaught exception causes test to fail
63    */
64   public void runTest() throws Throwable {
65      Document doc;
66      NodeList elementList;
67      NodeList childList;
68      Node childNode;
69      Node newChild;
70      Node memberNode;
71      String memberName;
72      java.util.List refreshedActual = new java.util.ArrayList();
73
74      java.util.List actual = new java.util.ArrayList();
75
76      int nodeType;
77      java.util.List expected = new java.util.ArrayList();
78      expected.add("strong");
79      expected.add("code");
80      expected.add("sup");
81      expected.add("var");
82      expected.add("acronym");
83      expected.add("em");
84
85      Node appendedChild;
86      doc = (Document) load("hc_staff", true);
87      elementList = doc.getElementsByTagName("p");
88      childNode = elementList.item(1);
89      childList = ((Element) /*Node */childNode).getElementsByTagName("*");
90      newChild = childList.item(0);
91      appendedChild = childNode.appendChild(newChild);
92      for (int indexN10085 = 0; indexN10085 < childList.getLength(); indexN10085++) {
93          memberNode = (Node) childList.item(indexN10085);
94    memberName = memberNode.getNodeName();
95      actual.add(memberName);
96        }
97      assertEqualsAutoCase("element", "liveByTagName", expected, actual);
98        childList = childNode.getChildNodes();
99      for (int indexN1009C = 0; indexN1009C < childList.getLength(); indexN1009C++) {
100          memberNode = (Node) childList.item(indexN1009C);
101    nodeType = (int) memberNode.getNodeType();
102
103      if (equals(1, nodeType)) {
104          memberName = memberNode.getNodeName();
105      refreshedActual.add(memberName);
106      }
107      }
108      assertEqualsAutoCase("element", "refreshedChildNodes", expected, refreshedActual);
109        }
110   /**
111    *  Gets URI that identifies the test.
112    *  @return uri identifier of test
113    */
114   public String getTargetURI() {
115      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeappendchildchildexists";
116   }
117   /**
118    * Runs this test from the command line.
119    * @param args command line arguments
120    */
121   public static void main(final String[] args) {
122        DOMTestCase.doMain(hc_nodeappendchildchildexists.class, args);
123   }
124}
125
126