Home | History | Annotate | Download | only in core
      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  *     The range of valid child node indices is 0 thru length -1
     32  *
     33  *    Create a list of all the children elements of the third
     34  *    employee and traverse the list from index=0 thru
     35  *    length -1.
     36 * @author NIST
     37 * @author Mary Brady
     38 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337</a>
     39 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136</a>
     40 */
     41 public final class nodelisttraverselist extends DOMTestCase {
     42 
     43    /**
     44     * Constructor.
     45     * @param factory document factory, may not be null
     46     * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
     47     */
     48    public nodelisttraverselist(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
     49       super(factory);
     50 
     51     //
     52     //   check if loaded documents are supported for content type
     53     //
     54     String contentType = getContentType();
     55     preload(contentType, "staff", false);
     56     }
     57 
     58    /**
     59     * Runs the test case.
     60     * @throws Throwable Any uncaught exception causes test to fail
     61     */
     62    public void runTest() throws Throwable {
     63       Document doc;
     64       NodeList elementList;
     65       Node employeeNode;
     66       NodeList employeeList;
     67       Node child;
     68       String childName;
     69       java.util.List result = new java.util.ArrayList();
     70 
     71       int length;
     72       java.util.List expectedWhitespace = new java.util.ArrayList();
     73       expectedWhitespace.add("#text");
     74       expectedWhitespace.add("employeeId");
     75       expectedWhitespace.add("#text");
     76       expectedWhitespace.add("name");
     77       expectedWhitespace.add("#text");
     78       expectedWhitespace.add("position");
     79       expectedWhitespace.add("#text");
     80       expectedWhitespace.add("salary");
     81       expectedWhitespace.add("#text");
     82       expectedWhitespace.add("gender");
     83       expectedWhitespace.add("#text");
     84       expectedWhitespace.add("address");
     85       expectedWhitespace.add("#text");
     86 
     87       java.util.List expectedNoWhitespace = new java.util.ArrayList();
     88       expectedNoWhitespace.add("employeeId");
     89       expectedNoWhitespace.add("name");
     90       expectedNoWhitespace.add("position");
     91       expectedNoWhitespace.add("salary");
     92       expectedNoWhitespace.add("gender");
     93       expectedNoWhitespace.add("address");
     94 
     95       doc = (Document) load("staff", false);
     96       elementList = doc.getElementsByTagName("employee");
     97       employeeNode = elementList.item(2);
     98       employeeList = employeeNode.getChildNodes();
     99       length = (int) employeeList.getLength();
    100       for (int indexN100A4 = 0; indexN100A4 < employeeList.getLength(); indexN100A4++) {
    101           child = (Node) employeeList.item(indexN100A4);
    102     childName = child.getNodeName();
    103       result.add(childName);
    104         }
    105 
    106       if (equals(6, length)) {
    107           assertEquals("nowhitespace", expectedNoWhitespace, result);
    108       } else {
    109           assertEquals("whitespace", expectedWhitespace, result);
    110       }
    111 
    112     }
    113    /**
    114     *  Gets URI that identifies the test.
    115     *  @return uri identifier of test
    116     */
    117    public String getTargetURI() {
    118       return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodelisttraverselist";
    119    }
    120    /**
    121     * Runs this test from the command line.
    122     * @param args command line arguments
    123     */
    124    public static void main(final String[] args) {
    125         DOMTestCase.doMain(nodelisttraverselist.class, args);
    126    }
    127 }
    128 
    129