1
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 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 *     The "getNamedItem(name)" method returns a node of any
32 *    type specified by name.
33 *
34 *    Retrieve the second employee and create a NamedNodeMap
35 *    listing of the attributes of the last child.  Once the
36 *    list is created an invocation of the "getNamedItem(name)"
37 *    method is done with name="street".  This should result
38 *    in the method returning an Attr node.
39* @author NIST
40* @author Mary Brady
41* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549</a>
42* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096</a>
43* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024</a>
44* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403</a>
45*/
46public final class namednodemapreturnattrnode extends DOMTestCase {
47
48   /**
49    * Constructor.
50    * @param factory document factory, may not be null
51    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
52    */
53   public namednodemapreturnattrnode(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
54      super(factory);
55
56    //
57    //   check if loaded documents are supported for content type
58    //
59    String contentType = getContentType();
60    preload(contentType, "staff", false);
61    }
62
63   /**
64    * Runs the test case.
65    * @throws Throwable Any uncaught exception causes test to fail
66    */
67   public void runTest() throws Throwable {
68      Document doc;
69      NodeList elementList;
70      Node testEmployee;
71      NamedNodeMap attributes;
72      Node streetAttr;
73      String attrName;
74      doc = (Document) load("staff", false);
75      elementList = doc.getElementsByTagName("address");
76      testEmployee = elementList.item(1);
77      attributes = testEmployee.getAttributes();
78      streetAttr = attributes.getNamedItem("street");
79      assertInstanceOf("typeAssert", Attr.class, streetAttr);
80attrName = streetAttr.getNodeName();
81      assertEquals("nodeName", "street", attrName);
82      attrName = ((Attr) /*Node */streetAttr).getName();
83      assertEquals("attrName", "street", attrName);
84      }
85   /**
86    *  Gets URI that identifies the test.
87    *  @return uri identifier of test
88    */
89   public String getTargetURI() {
90      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapreturnattrnode";
91   }
92   /**
93    * Runs this test from the command line.
94    * @param args command line arguments
95    */
96   public static void main(final String[] args) {
97        DOMTestCase.doMain(namednodemapreturnattrnode.class, args);
98   }
99}
100
101