OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / dom / src / test / java / org / w3c / domts / level1 / core / hc_namednodemapsetnameditemthatexists.java
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 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
15 PURPOSE.
16 See W3C License http://www.w3.org/Consortium/Legal/ for more details.
17
18 */
19
20 package org.w3c.domts.level1.core;
21
22 import org.w3c.dom.*;
23
24
25 import org.w3c.domts.DOMTestCase;
26 import org.w3c.domts.DOMTestDocumentBuilderFactory;
27
28
29
30 /**
31  *     If the node to be added by the "setNamedItem(arg)" method 
32  *    already exists in the NamedNodeMap, it is replaced by
33  *    the new one.
34  *    
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
43  *    the new one.   
44  *    This node is then retrieved using the "getNamedItem(name)"
45  *    method.  This test uses the "createAttribute(name)"
46  *    method from the document interface
47 * @author Curt Arnold
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>
50 */
51 public final class hc_namednodemapsetnameditemthatexists extends DOMTestCase {
52
53    /**
54     * Constructor.
55     * @param factory document factory, may not be null
56     * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
57     */
58    public hc_namednodemapsetnameditemthatexists(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
59       super(factory);
60
61     //
62     //   check if loaded documents are supported for content type
63     //
64     String contentType = getContentType();
65     preload(contentType, "hc_staff", true);
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       NodeList elementList;
75       Attr newAttribute;
76       Node testAddress;
77       NamedNodeMap attributes;
78       Attr districtNode;
79       String attrValue;
80       Node setNode;
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);
90       }
91    /**
92     *  Gets URI that identifies the test.
93     *  @return uri identifier of test
94     */
95    public String getTargetURI() {
96       return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapsetnameditemthatexists";
97    }
98    /**
99     * Runs this test from the command line.
100     * @param args command line arguments
101     */
102    public static void main(final String[] args) {
103         DOMTestCase.doMain(hc_namednodemapsetnameditemthatexists.class, args);
104    }
105 }
106