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 9 Copyright (c) 2001 World Wide Web Consortium, 10 (Massachusetts Institute of Technology, Institut National de 11 Recherche en Informatique et en Automatique, Keio University). All 12 Rights Reserved. This program is distributed under the W3C's Software 13 Intellectual Property License. This program is distributed in the 14 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 16 PURPOSE. 17 18 See W3C License http://www.w3.org/Consortium/Legal/ for more details. 19 20 21 */ 22 23 package org.w3c.domts.level2.core; 24 25 import org.w3c.dom.*; 26 27 28 import org.w3c.domts.DOMTestCase; 29 import org.w3c.domts.DOMTestDocumentBuilderFactory; 30 31 32 33 /** 34 * The "normalize()" method puts all the nodes in the full 35 * depth of the sub-tree underneath this element into a 36 * "normal" form. 37 * 38 * Retrieve the third employee and access its second child. 39 * This child contains a block of text that is spread 40 * across multiple lines. The content of the "name" child 41 * should be parsed and treated as a single Text node. 42 * This appears to be a duplicate of elementnormalize.xml in DOM L1 Test Suite 43 * @author NIST 44 * @author Mary Brady 45 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-normalize">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-normalize</a> 46 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-72AB8359">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-72AB8359</a> 47 */ 48 public final class normalize01 extends DOMTestCase { 49 50 /** 51 * Constructor. 52 * @param factory document factory, may not be null 53 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 54 */ 55 public normalize01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 56 super(factory); 57 58 // 59 // check if loaded documents are supported for content type 60 // 61 String contentType = getContentType(); 62 preload(contentType, "staff", false); 63 } 64 65 /** 66 * Runs the test case. 67 * @throws Throwable Any uncaught exception causes test to fail 68 */ 69 public void runTest() throws Throwable { 70 Document doc; 71 Element root; 72 NodeList elementList; 73 Node firstChild; 74 NodeList textList; 75 CharacterData textNode; 76 String data; 77 doc = (Document) load("staff", false); 78 root = doc.getDocumentElement(); 79 root.normalize(); 80 elementList = root.getElementsByTagName("name"); 81 firstChild = elementList.item(2); 82 textList = firstChild.getChildNodes(); 83 textNode = (CharacterData) textList.item(0); 84 data = textNode.getData(); 85 assertEquals("data", "Roger\n Jones", data); 86 } 87 /** 88 * Gets URI that identifies the test. 89 * @return uri identifier of test 90 */ 91 public String getTargetURI() { 92 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/normalize01"; 93 } 94 /** 95 * Runs this test from the command line. 96 * @param args command line arguments 97 */ 98 public static void main(final String[] args) { 99 DOMTestCase.doMain(normalize01.class, args); 100 } 101 } 102 103