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 textual data from the last child of the 32 * second employee. That node is composed of two 33 * EntityReference nodes and two Text nodes. After 34 * the content node is parsed, the "address" Element 35 * should contain four children with each one of the 36 * EntityReferences containing one child. 37* @author NIST 38* @author Mary Brady 39* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987</a> 40* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490</a> 41* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614</a> 42*/ 43public final class textparseintolistofelements 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 textparseintolistofelements(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, "staff", false); 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 Node addressNode; 68 NodeList childList; 69 Node child; 70 int length; 71 String value; 72 Node grandChild; 73 java.util.List result = new java.util.ArrayList(); 74 75 java.util.List expectedNormal = new java.util.ArrayList(); 76 expectedNormal.add("1900 Dallas Road"); 77 expectedNormal.add(" Dallas, "); 78 expectedNormal.add("Texas"); 79 expectedNormal.add("\n 98554"); 80 81 java.util.List expectedExpanded = new java.util.ArrayList(); 82 expectedExpanded.add("1900 Dallas Road Dallas, Texas\n 98554"); 83 84 doc = (Document) load("staff", false); 85 elementList = doc.getElementsByTagName("address"); 86 addressNode = elementList.item(1); 87 childList = addressNode.getChildNodes(); 88 length = (int) childList.getLength(); 89 for (int indexN1007F = 0; indexN1007F < childList.getLength(); indexN1007F++) { 90 child = (Node) childList.item(indexN1007F); 91 value = child.getNodeValue(); 92 93 if ((value == null)) { 94 grandChild = child.getFirstChild(); 95 assertNotNull("grandChildNotNull", grandChild); 96 value = grandChild.getNodeValue(); 97 result.add(value); 98 } else { 99 result.add(value); 100 } 101 102 } 103 104 if (equals(4, length)) { 105 assertEquals("assertEqNormal", expectedNormal, result); 106 } else { 107 assertEquals("assertEqCoalescing", expectedExpanded, result); 108 } 109 110 } 111 /** 112 * Gets URI that identifies the test. 113 * @return uri identifier of test 114 */ 115 public String getTargetURI() { 116 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textparseintolistofelements"; 117 } 118 /** 119 * Runs this test from the command line. 120 * @param args command line arguments 121 */ 122 public static void main(final String[] args) { 123 DOMTestCase.doMain(textparseintolistofelements.class, args); 124 } 125} 126 127