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-2004 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 * Retrieve the second acronym element and invoke 32 * the cloneNode method. The 33 * duplicate node returned by the method should copy the 34 * attributes associated with this node. 35* @author Curt Arnold 36* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096</a> 37* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=236">http://www.w3.org/Bugs/Public/show_bug.cgi?id=236</a> 38* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=184">http://www.w3.org/Bugs/Public/show_bug.cgi?id=184</a> 39*/ 40public final class hc_nodecloneattributescopied extends DOMTestCase { 41 42 /** 43 * Constructor. 44 * @param factory document factory, may not be null 45 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 46 */ 47 public hc_nodecloneattributescopied(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 48 super(factory); 49 50 // 51 // check if loaded documents are supported for content type 52 // 53 String contentType = getContentType(); 54 preload(contentType, "hc_staff", true); 55 } 56 57 /** 58 * Runs the test case. 59 * @throws Throwable Any uncaught exception causes test to fail 60 */ 61 public void runTest() throws Throwable { 62 Document doc; 63 NodeList elementList; 64 Node addressNode; 65 Node clonedNode; 66 NamedNodeMap attributes; 67 Node attributeNode; 68 String attributeName; 69 java.util.Collection result = new java.util.ArrayList(); 70 71 java.util.Collection htmlExpected = new java.util.ArrayList(); 72 htmlExpected.add("class"); 73 htmlExpected.add("title"); 74 75 java.util.Collection expected = new java.util.ArrayList(); 76 expected.add("class"); 77 expected.add("title"); 78 expected.add("dir"); 79 80 doc = (Document) load("hc_staff", true); 81 elementList = doc.getElementsByTagName("acronym"); 82 addressNode = elementList.item(1); 83 clonedNode = addressNode.cloneNode(false); 84 attributes = clonedNode.getAttributes(); 85 for (int indexN10076 = 0; indexN10076 < attributes.getLength(); indexN10076++) { 86 attributeNode = (Node) attributes.item(indexN10076); 87 attributeName = attributeNode.getNodeName(); 88 result.add(attributeName); 89 } 90 91 if (("text/html".equals(getContentType()))) { 92 assertEqualsIgnoreCase("nodeNames_html", htmlExpected, result); 93} else { 94 assertEquals("nodeNames", expected, result); 95 } 96 97 } 98 /** 99 * Gets URI that identifies the test. 100 * @return uri identifier of test 101 */ 102 public String getTargetURI() { 103 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodecloneattributescopied"; 104 } 105 /** 106 * Runs this test from the command line. 107 * @param args command line arguments 108 */ 109 public static void main(final String[] args) { 110 DOMTestCase.doMain(hc_nodecloneattributescopied.class, args); 111 } 112} 113 114