1 2 /* 3 This Java source file was generated by test-to-java.xsl 4 and is a derived work from the source document. 5 The source document contained the following notice: 6 7 8 Copyright (c) 2001-2004 World Wide Web Consortium, 9 (Massachusetts Institute of Technology, Institut National de 10 Recherche en Informatique et en Automatique, Keio University). All 11 Rights Reserved. This program is distributed under the W3C's Software 12 Intellectual Property License. This program is distributed in the 13 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 PURPOSE. 16 See W3C License http://www.w3.org/Consortium/Legal/ for more details. 17 18 */ 19 20 package org.w3c.domts.level1.core; 21 22 import org.w3c.dom.*; 23 24 25 import org.w3c.domts.DOMTestCase; 26 import org.w3c.domts.DOMTestDocumentBuilderFactory; 27 28 29 30 /** 31 * Retrieve the entire DOM document and invoke its 32 * "getElementsByTagName(tagName)" method with tagName 33 * equal to "*". The method should return a NodeList 34 * that contains all the elements of the document. 35 * @author Curt Arnold 36 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094</a> 37 * @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=251">http://www.w3.org/Bugs/Public/show_bug.cgi?id=251</a> 38 */ 39 public final class hc_documentgetelementsbytagnametotallength extends DOMTestCase { 40 41 /** 42 * Constructor. 43 * @param factory document factory, may not be null 44 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 45 */ 46 public hc_documentgetelementsbytagnametotallength(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 47 super(factory); 48 49 // 50 // check if loaded documents are supported for content type 51 // 52 String contentType = getContentType(); 53 preload(contentType, "hc_staff", false); 54 } 55 56 /** 57 * Runs the test case. 58 * @throws Throwable Any uncaught exception causes test to fail 59 */ 60 public void runTest() throws Throwable { 61 Document doc; 62 NodeList nameList; 63 java.util.List expectedNames = new java.util.ArrayList(); 64 expectedNames.add("html"); 65 expectedNames.add("head"); 66 expectedNames.add("meta"); 67 expectedNames.add("title"); 68 expectedNames.add("script"); 69 expectedNames.add("script"); 70 expectedNames.add("script"); 71 expectedNames.add("body"); 72 expectedNames.add("p"); 73 expectedNames.add("em"); 74 expectedNames.add("strong"); 75 expectedNames.add("code"); 76 expectedNames.add("sup"); 77 expectedNames.add("var"); 78 expectedNames.add("acronym"); 79 expectedNames.add("p"); 80 expectedNames.add("em"); 81 expectedNames.add("strong"); 82 expectedNames.add("code"); 83 expectedNames.add("sup"); 84 expectedNames.add("var"); 85 expectedNames.add("acronym"); 86 expectedNames.add("p"); 87 expectedNames.add("em"); 88 expectedNames.add("strong"); 89 expectedNames.add("code"); 90 expectedNames.add("sup"); 91 expectedNames.add("var"); 92 expectedNames.add("acronym"); 93 expectedNames.add("p"); 94 expectedNames.add("em"); 95 expectedNames.add("strong"); 96 expectedNames.add("code"); 97 expectedNames.add("sup"); 98 expectedNames.add("var"); 99 expectedNames.add("acronym"); 100 expectedNames.add("p"); 101 expectedNames.add("em"); 102 expectedNames.add("strong"); 103 expectedNames.add("code"); 104 expectedNames.add("sup"); 105 expectedNames.add("var"); 106 expectedNames.add("acronym"); 107 108 java.util.List svgExpectedNames = new java.util.ArrayList(); 109 svgExpectedNames.add("svg"); 110 svgExpectedNames.add("rect"); 111 svgExpectedNames.add("script"); 112 svgExpectedNames.add("head"); 113 svgExpectedNames.add("meta"); 114 svgExpectedNames.add("title"); 115 svgExpectedNames.add("body"); 116 svgExpectedNames.add("p"); 117 svgExpectedNames.add("em"); 118 svgExpectedNames.add("strong"); 119 svgExpectedNames.add("code"); 120 svgExpectedNames.add("sup"); 121 svgExpectedNames.add("var"); 122 svgExpectedNames.add("acronym"); 123 svgExpectedNames.add("p"); 124 svgExpectedNames.add("em"); 125 svgExpectedNames.add("strong"); 126 svgExpectedNames.add("code"); 127 svgExpectedNames.add("sup"); 128 svgExpectedNames.add("var"); 129 svgExpectedNames.add("acronym"); 130 svgExpectedNames.add("p"); 131 svgExpectedNames.add("em"); 132 svgExpectedNames.add("strong"); 133 svgExpectedNames.add("code"); 134 svgExpectedNames.add("sup"); 135 svgExpectedNames.add("var"); 136 svgExpectedNames.add("acronym"); 137 svgExpectedNames.add("p"); 138 svgExpectedNames.add("em"); 139 svgExpectedNames.add("strong"); 140 svgExpectedNames.add("code"); 141 svgExpectedNames.add("sup"); 142 svgExpectedNames.add("var"); 143 svgExpectedNames.add("acronym"); 144 svgExpectedNames.add("p"); 145 svgExpectedNames.add("em"); 146 svgExpectedNames.add("strong"); 147 svgExpectedNames.add("code"); 148 svgExpectedNames.add("sup"); 149 svgExpectedNames.add("var"); 150 svgExpectedNames.add("acronym"); 151 152 java.util.List actualNames = new java.util.ArrayList(); 153 154 Element thisElement; 155 String thisTag; 156 doc = (Document) load("hc_staff", false); 157 nameList = doc.getElementsByTagName("*"); 158 for (int indexN10148 = 0; indexN10148 < nameList.getLength(); indexN10148++) { 159 thisElement = (Element) nameList.item(indexN10148); 160 thisTag = thisElement.getTagName(); 161 actualNames.add(thisTag); 162 } 163 164 if (("image/svg+xml".equals(getContentType()))) { 165 assertEqualsAutoCase("element", "svgTagNames", svgExpectedNames, actualNames); 166 } else { 167 assertEqualsAutoCase("element", "tagNames", expectedNames, actualNames); 168 } 169 170 } 171 /** 172 * Gets URI that identifies the test. 173 * @return uri identifier of test 174 */ 175 public String getTargetURI() { 176 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_documentgetelementsbytagnametotallength"; 177 } 178 /** 179 * Runs this test from the command line. 180 * @param args command line arguments 181 */ 182 public static void main(final String[] args) { 183 DOMTestCase.doMain(hc_documentgetelementsbytagnametotallength.class, args); 184 } 185 } 186 187