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
8
9Copyright (c) 2001 World Wide Web Consortium,
10(Massachusetts Institute of Technology, Institut National de
11Recherche en Informatique et en Automatique, Keio University).  All
12Rights Reserved.  This program is distributed under the W3C's Software
13Intellectual Property License.  This program is distributed in the
14hope that it will be useful, but WITHOUT ANY WARRANTY; without even
15the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16PURPOSE.
17
18See W3C License http://www.w3.org/Consortium/Legal/ for more details.
19
20
21*/
22
23package org.w3c.domts.level2.core;
24
25import org.w3c.dom.*;
26
27
28import org.w3c.domts.DOMTestCase;
29import org.w3c.domts.DOMTestDocumentBuilderFactory;
30
31
32
33/**
34 *  The method getElementsByTagNameNS returns a NodeList of all the Elements with
35 *  a given local name and namespace URI in the order in which they are encountered
36 *  in a preorder traversal of the Document tree.
37 *
38 *
39 *  Create a new element having a local name="employeeId" belonging to the namespace "test"
40 *  and append it to this document.  Invoke the getElementsByTagNameNS method on a this
41 *  Document object with the values of namespaceURI=* and localName="elementId".  This
42 *  should return a nodeList of 6 item.  Check the length of the nodeList returned.
43* @author IBM
44* @author Neil Delima
45* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core">http://www.w3.org/TR/DOM-Level-2-Core/core</a>
46* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBTNNS</a>
47*/
48public final class documentgetelementsbytagnameNS02 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 documentgetelementsbytagnameNS02(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
56
57      org.w3c.domts.DocumentBuilderSetting[] settings =
58          new org.w3c.domts.DocumentBuilderSetting[] {
59org.w3c.domts.DocumentBuilderSetting.namespaceAware
60        };
61        DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
62        setFactory(testFactory);
63
64    //
65    //   check if loaded documents are supported for content type
66    //
67    String contentType = getContentType();
68    preload(contentType, "staffNS", true);
69    }
70
71   /**
72    * Runs the test case.
73    * @throws Throwable Any uncaught exception causes test to fail
74    */
75   public void runTest() throws Throwable {
76      Document doc;
77      Element docElem;
78      Element element;
79      NodeList childList;
80      Node appendedChild;
81      doc = (Document) load("staffNS", true);
82      docElem = doc.getDocumentElement();
83      element = doc.createElementNS("test", "employeeId");
84      appendedChild = docElem.appendChild(element);
85      childList = doc.getElementsByTagNameNS("*", "employeeId");
86      assertSize("documentgetelementsbytagnameNS02", 6, childList);
87      }
88   /**
89    *  Gets URI that identifies the test.
90    *  @return uri identifier of test
91    */
92   public String getTargetURI() {
93      return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentgetelementsbytagnameNS02";
94   }
95   /**
96    * Runs this test from the command line.
97    * @param args command line arguments
98    */
99   public static void main(final String[] args) {
100        DOMTestCase.doMain(documentgetelementsbytagnameNS02.class, args);
101   }
102}
103
104