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:
9 Copyright (c) 2001-2004 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
18 See W3C License http://www.w3.org/Consortium/Legal/ for more details.
23 package org.w3c.domts.level2.core;
28 import org.w3c.domts.DOMTestCase;
29 import org.w3c.domts.DOMTestDocumentBuilderFactory;
34 * The method setNamedItemNS adds a node using its namespaceURI and localName and
35 * raises a WRONG_DOCUMENT_ERR if arg was created from a different document than the
36 * one that created this map.
38 * Retreieve the second element whose local name is address and its attribute into a named node map.
39 * Do the same for another document and retreive its street attribute. Call the setNamedItemNS
40 * using the first namedNodeMap and the retreive street attribute of the second. This should
41 * raise a WRONG_DOCUMENT_ERR.
44 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS</a>
45 * @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>
46 * @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=408">http://www.w3.org/Bugs/Public/show_bug.cgi?id=408</a>
48 public final class namednodemapsetnameditemns03 extends DOMTestCase {
52 * @param factory document factory, may not be null
53 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
55 public namednodemapsetnameditemns03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException {
57 org.w3c.domts.DocumentBuilderSetting[] settings =
58 new org.w3c.domts.DocumentBuilderSetting[] {
59 org.w3c.domts.DocumentBuilderSetting.namespaceAware
61 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
62 setFactory(testFactory);
65 // check if loaded documents are supported for content type
67 String contentType = getContentType();
68 preload(contentType, "staffNS", true);
69 preload(contentType, "staffNS", true);
74 * @throws Throwable Any uncaught exception causes test to fail
76 public void runTest() throws Throwable {
79 NamedNodeMap attributes;
80 NamedNodeMap attributesAlt;
82 NodeList elementListAlt;
89 doc = (Document) load("staffNS", true);
90 elementList = doc.getElementsByTagNameNS("*", "address");
91 element = (Element) elementList.item(1);
92 attributes = element.getAttributes();
93 docAlt = (Document) load("staffNS", true);
94 elementListAlt = docAlt.getElementsByTagNameNS("*", "address");
95 elementAlt = (Element) elementListAlt.item(1);
96 attributesAlt = elementAlt.getAttributes();
97 attr = (Attr) attributesAlt.getNamedItemNS(nullNS, "street");
98 newNode = attributesAlt.removeNamedItemNS(nullNS, "street");
101 boolean success = false;
103 newNode = attributes.setNamedItemNS(attr);
104 } catch (DOMException ex) {
105 success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
107 assertTrue("throw_WRONG_DOCUMENT_ERR", success);
111 * Gets URI that identifies the test.
112 * @return uri identifier of test
114 public String getTargetURI() {
115 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapsetnameditemns03";
118 * Runs this test from the command line.
119 * @param args command line arguments
121 public static void main(final String[] args) {
122 DOMTestCase.doMain(namednodemapsetnameditemns03.class, args);