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-2003 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 method getNamespaceURI returns the namespace URI of this node, or null if it is unspecified 35 * For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with 36 * a DOM Level 1 method, such as createElement from the Document interface, this is always null. 37 * 38 * Ceate two new element nodes and atribute nodes, with and without namespace prefixes. 39 * Retreive their namespaceURI's using getNamespaceURI and verrify if it is correct. 40 * @author IBM 41 * @author Neil Delima 42 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSname">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSname</a> 43 * @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=259">http://www.w3.org/Bugs/Public/show_bug.cgi?id=259</a> 44 */ 45 public final class nodegetnamespaceuri03 extends DOMTestCase { 46 47 /** 48 * Constructor. 49 * @param factory document factory, may not be null 50 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 51 */ 52 public nodegetnamespaceuri03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 53 54 org.w3c.domts.DocumentBuilderSetting[] settings = 55 new org.w3c.domts.DocumentBuilderSetting[] { 56 org.w3c.domts.DocumentBuilderSetting.namespaceAware 57 }; 58 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); 59 setFactory(testFactory); 60 61 // 62 // check if loaded documents are supported for content type 63 // 64 String contentType = getContentType(); 65 preload(contentType, "staff", false); 66 } 67 68 /** 69 * Runs the test case. 70 * @throws Throwable Any uncaught exception causes test to fail 71 */ 72 public void runTest() throws Throwable { 73 Document doc; 74 Element element; 75 Element elementNS; 76 Attr attr; 77 Attr attrNS; 78 String elemNSURI; 79 String elemNSURINull; 80 String attrNSURI; 81 String attrNSURINull; 82 String nullNS = null; 83 84 doc = (Document) load("staff", false); 85 element = doc.createElementNS(nullNS, "elem"); 86 elementNS = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "qual:qelem"); 87 attr = doc.createAttributeNS(nullNS, "attr"); 88 attrNS = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "qual:qattr"); 89 elemNSURI = elementNS.getNamespaceURI(); 90 elemNSURINull = element.getNamespaceURI(); 91 attrNSURI = attrNS.getNamespaceURI(); 92 attrNSURINull = attr.getNamespaceURI(); 93 assertEquals("nodegetnamespaceuri03_elemNSURI", "http://www.w3.org/DOM/Test/elem", elemNSURI); 94 assertNull("nodegetnamespaceuri03_1", elemNSURINull); 95 assertEquals("nodegetnamespaceuri03_attrNSURI", "http://www.w3.org/DOM/Test/attr", attrNSURI); 96 assertNull("nodegetnamespaceuri03_2", attrNSURINull); 97 } 98 /** 99 * Gets URI that identifies the test. 100 * @return uri identifier of test 101 */ 102 public String getTargetURI() { 103 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodegetnamespaceuri03"; 104 } 105 /** 106 * Runs this test from the command line. 107 * @param args command line arguments 108 */ 109 public static void main(final String[] args) { 110 DOMTestCase.doMain(nodegetnamespaceuri03.class, args); 111 } 112 } 113 114