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-2003 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 Curt Arnold
     37 * @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>
     38 * @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>
     39 * @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=246">http://www.w3.org/Bugs/Public/show_bug.cgi?id=246</a>
     40 */
     41 public final class hc_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 hc_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, "hc_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       int nodeType;
     70       java.util.List result = new java.util.ArrayList();
     71 
     72       java.util.List expected = new java.util.ArrayList();
     73       expected.add("em");
     74       expected.add("strong");
     75       expected.add("code");
     76       expected.add("sup");
     77       expected.add("var");
     78       expected.add("acronym");
     79 
     80       doc = (Document) load("hc_staff", false);
     81       elementList = doc.getElementsByTagName("p");
     82       employeeNode = elementList.item(2);
     83       employeeList = employeeNode.getChildNodes();
     84       for (int indexN10073 = 0; indexN10073 < employeeList.getLength(); indexN10073++) {
     85           child = (Node) employeeList.item(indexN10073);
     86     nodeType = (int) child.getNodeType();
     87       childName = child.getNodeName();
     88 
     89       if (equals(1, nodeType)) {
     90           result.add(childName);
     91       } else {
     92           assertEquals("textNodeType", 3, nodeType);
     93       assertEquals("textNodeName", "#text", childName);
     94       }
     95 
     96       }
     97       assertEqualsAutoCase("element", "nodeNames", expected, result);
     98         }
     99    /**
    100     *  Gets URI that identifies the test.
    101     *  @return uri identifier of test
    102     */
    103    public String getTargetURI() {
    104       return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodelisttraverselist";
    105    }
    106    /**
    107     * Runs this test from the command line.
    108     * @param args command line arguments
    109     */
    110    public static void main(final String[] args) {
    111         DOMTestCase.doMain(hc_nodelisttraverselist.class, args);
    112    }
    113 }
    114 
    115