blob: 609009a8b4b25f30c99e7e9549ce3406f576399b [file] [log] [blame]
The Android Open Source Projectb5de22c2012-04-01 00:00:00 -07001
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
8Copyright (c) 2001-2004 World Wide Web Consortium,
9(Massachusetts Institute of Technology, Institut National de
10Recherche en Informatique et en Automatique, Keio University). All
11Rights Reserved. This program is distributed under the W3C's Software
12Intellectual Property License. This program is distributed in the
13hope that it will be useful, but WITHOUT ANY WARRANTY; without even
14the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15PURPOSE.
16See W3C License http://www.w3.org/Consortium/Legal/ for more details.
17
18*/
19
20package org.w3c.domts.level1.core;
21
22import org.w3c.dom.*;
23
24
25import org.w3c.domts.DOMTestCase;
26import org.w3c.domts.DOMTestDocumentBuilderFactory;
27
28
29
30/**
31 * Retrieve the second "p" element and create a NamedNodeMap
32 * object from the attributes of the last child by
33 * invoking the "getAttributes()" method. Once the
34 * list is created an invocation of the "setNamedItem(arg)"
35 * method is done with arg=newAttr, where newAttr is a
36 * new Attr Node previously created. The "setNamedItem(arg)"
37 * method should add then new node to the NamedNodeItem
38 * object by using its "nodeName" attribute("lang').
39 * This node is then retrieved using the "getNamedItem(name)"
40 * method.
41* @author Curt Arnold
42* @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>
43* @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>
44* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=236">http://www.w3.org/Bugs/Public/show_bug.cgi?id=236</a>
45* @see <a href="http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html">http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html</a>
46* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=243">http://www.w3.org/Bugs/Public/show_bug.cgi?id=243</a>
47*/
48public final class hc_namednodemapsetnameditem 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 hc_namednodemapsetnameditem(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException {
56 super(factory);
57
58 //
59 // check if loaded documents are supported for content type
60 //
61 String contentType = getContentType();
62 preload(contentType, "hc_staff", true);
63 }
64
65 /**
66 * Runs the test case.
67 * @throws Throwable Any uncaught exception causes test to fail
68 */
69 public void runTest() throws Throwable {
70 Document doc;
71 NodeList elementList;
72 Attr newAttribute;
73 Node testAddress;
74 NamedNodeMap attributes;
75 Attr districtNode;
76 String attrName;
77 Node setNode;
78 doc = (Document) load("hc_staff", true);
79 elementList = doc.getElementsByTagName("acronym");
80 testAddress = elementList.item(1);
81 newAttribute = doc.createAttribute("lang");
82 attributes = testAddress.getAttributes();
83 setNode = attributes.setNamedItem(newAttribute);
84 districtNode = (Attr) attributes.getNamedItem("lang");
85 attrName = districtNode.getNodeName();
86 assertEqualsAutoCase("attribute", "nodeName", "lang", attrName);
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/level1/core/hc_namednodemapsetnameditem";
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(hc_namednodemapsetnameditem.class, args);
101 }
102}
103