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:
8 Copyright (c) 2001 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
16 See W3C License http://www.w3.org/Consortium/Legal/ for more details.
20 package org.w3c.domts.level1.core;
25 import org.w3c.domts.DOMTestCase;
26 import org.w3c.domts.DOMTestDocumentBuilderFactory;
31 * If the node to be added by the "setNamedItem(arg)" method
32 * already exists in the NamedNodeMap, it is replaced by
35 * Retrieve the second employee and create a NamedNodeMap
36 * object from the attributes of the last child by
37 * invoking the "getAttributes()" method. Once the
38 * list is created an invocation of the "setNamedItem(arg)"
39 * method is done with arg=newAttr, where newAttr is a
40 * new Attr Node previously created and whose node name
41 * already exists in the map. The "setNamedItem(arg)"
42 * method should replace the already existing node with
44 * This node is then retrieved using the "getNamedItem(name)"
45 * method. This test uses the "createAttribute(name)"
46 * method from the document interface
48 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788</a>
49 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9</a>
51 public final class hc_namednodemapsetnameditemthatexists extends DOMTestCase {
55 * @param factory document factory, may not be null
56 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
58 public hc_namednodemapsetnameditemthatexists(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException {
62 // check if loaded documents are supported for content type
64 String contentType = getContentType();
65 preload(contentType, "hc_staff", true);
70 * @throws Throwable Any uncaught exception causes test to fail
72 public void runTest() throws Throwable {
77 NamedNodeMap attributes;
81 doc = (Document) load("hc_staff", true);
82 elementList = doc.getElementsByTagName("acronym");
83 testAddress = elementList.item(1);
84 newAttribute = doc.createAttribute("class");
85 attributes = testAddress.getAttributes();
86 setNode = attributes.setNamedItem(newAttribute);
87 districtNode = (Attr) attributes.getNamedItem("class");
88 attrValue = districtNode.getNodeValue();
89 assertEquals("namednodemapSetNamedItemThatExistsAssert", "", attrValue);
92 * Gets URI that identifies the test.
93 * @return uri identifier of test
95 public String getTargetURI() {
96 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditemthatexists";
99 * Runs this test from the command line.
100 * @param args command line arguments
102 public static void main(final String[] args) {
103 DOMTestCase.doMain(hc_namednodemapsetnameditemthatexists.class, args);