The Android Open Source Project | 0eec464 | 2012-04-01 00:00:00 -0700 | [diff] [blame] | 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 "getElementsByTagNameNS(namespaceURI,localName)" method for a |
| 35 | * Element should return a new NodeList of all descendant Elements with a given |
| 36 | * localName and namespaceURI in the order they were encountered in a preorder |
| 37 | * traversal of the document tree. |
| 38 | * |
| 39 | * Invoke method getElementsByTagNameNS(namespaceURI,localName) on the document |
| 40 | * element with namespaceURI being "*" and localName is "employee". |
| 41 | * Method should return a new NodeList containing five Elements. |
| 42 | * Retrieve the FOURTH element whose name should be "emp:employee". |
| 43 | * Derived from getElementsByTagNameNS02 and reflects its interpretation |
| 44 | * that namespace="*" matches namespace unqualified tagnames. |
| 45 | * @author Curt Arnold |
| 46 | * @author Curt Arnold |
| 47 | * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1938918D</a> |
| 48 | */ |
| 49 | public final class getElementsByTagNameNS09 extends DOMTestCase { |
| 50 | |
| 51 | /** |
| 52 | * Constructor. |
| 53 | * @param factory document factory, may not be null |
| 54 | * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration |
| 55 | */ |
| 56 | public getElementsByTagNameNS09(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { |
| 57 | |
| 58 | org.w3c.domts.DocumentBuilderSetting[] settings = |
| 59 | new org.w3c.domts.DocumentBuilderSetting[] { |
| 60 | org.w3c.domts.DocumentBuilderSetting.namespaceAware |
| 61 | }; |
| 62 | DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); |
| 63 | setFactory(testFactory); |
| 64 | |
| 65 | // |
| 66 | // check if loaded documents are supported for content type |
| 67 | // |
| 68 | String contentType = getContentType(); |
| 69 | preload(contentType, "staffNS", false); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Runs the test case. |
| 74 | * @throws Throwable Any uncaught exception causes test to fail |
| 75 | */ |
| 76 | public void runTest() throws Throwable { |
| 77 | Document doc; |
| 78 | NodeList newList; |
| 79 | Element newElement; |
| 80 | String prefix; |
| 81 | String lname; |
| 82 | Element docElem; |
| 83 | doc = (Document) load("staffNS", false); |
| 84 | docElem = doc.getDocumentElement(); |
| 85 | newList = docElem.getElementsByTagNameNS("*", "employee"); |
| 86 | assertSize("employeeCount", 5, newList); |
| 87 | newElement = (Element) newList.item(3); |
| 88 | prefix = newElement.getPrefix(); |
| 89 | assertEquals("prefix", "emp", prefix); |
| 90 | lname = newElement.getLocalName(); |
| 91 | assertEquals("lname", "employee", lname); |
| 92 | } |
| 93 | /** |
| 94 | * Gets URI that identifies the test. |
| 95 | * @return uri identifier of test |
| 96 | */ |
| 97 | public String getTargetURI() { |
| 98 | return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/getElementsByTagNameNS09"; |
| 99 | } |
| 100 | /** |
| 101 | * Runs this test from the command line. |
| 102 | * @param args command line arguments |
| 103 | */ |
| 104 | public static void main(final String[] args) { |
| 105 | DOMTestCase.doMain(getElementsByTagNameNS09.class, args); |
| 106 | } |
| 107 | } |
| 108 | |