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
8
9Copyright (c) 2001 World Wide Web Consortium,
10(Massachusetts Institute of Technology, Institut National de
11Recherche en Informatique et en Automatique, Keio University).  All
12Rights Reserved.  This program is distributed under the W3C's Software
13Intellectual Property License.  This program is distributed in the
14hope that it will be useful, but WITHOUT ANY WARRANTY; without even
15the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16PURPOSE.
17
18See W3C License http://www.w3.org/Consortium/Legal/ for more details.
19
20
21*/
22
23package tests.org.w3c.dom;
24
25import dalvik.annotation.TestTargets;
26import dalvik.annotation.TestLevel;
27import dalvik.annotation.TestTargetNew;
28import dalvik.annotation.TestTargetClass;
29
30import org.w3c.dom.Node;
31import org.w3c.dom.Document;
32import org.w3c.dom.Element;
33import org.w3c.dom.Attr;
34
35import javax.xml.parsers.DocumentBuilder;
36
37/**
38 *  The method getLocalName returns the local part of the qualified name of this node.
39 *
40 *  Ceate two new element nodes and atribute nodes, with and without namespace prefixes.
41 *  Retreive the local part of their qualified names using getLocalName and verrify
42 *  if it is correct.
43* @author IBM
44* @author Neil Delima
45* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSLocalN">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSLocalN</a>
46*/
47@TestTargetClass(Node.class)
48public final class NodeGetLocalName extends DOMTestCase {
49
50    DOMDocumentBuilderFactory factory;
51
52    DocumentBuilder builder;
53
54    protected void setUp() throws Exception {
55        super.setUp();
56        try {
57            factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
58                    .getConfiguration1());
59            builder = factory.getBuilder();
60        } catch (Exception e) {
61            fail("Unexpected exception" + e.getMessage());
62        }
63    }
64
65    protected void tearDown() throws Exception {
66        factory = null;
67        builder = null;
68        super.tearDown();
69    }
70
71   /**
72    * Runs the test case.
73    * @throws Throwable Any uncaught exception causes test to fail
74    */
75    @TestTargetNew(
76        level = TestLevel.PARTIAL_COMPLETE,
77        notes = "Doesn't verify that getLocalName method returns null.",
78        method = "getLocalName",
79        args = {}
80    )
81   public void testGetLocalName() throws Throwable {
82      Document doc;
83      Element element;
84      Element qelement;
85      Attr attr;
86      Attr qattr;
87      String localElemName;
88      String localQElemName;
89      String localAttrName;
90      String localQAttrName;
91      doc = (Document) load("staff", builder);
92      element = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "elem");
93      qelement = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "qual:qelem");
94      attr = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "attr");
95      qattr = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "qual:qattr");
96      localElemName = element.getLocalName();
97      localQElemName = qelement.getLocalName();
98      localAttrName = attr.getLocalName();
99      localQAttrName = qattr.getLocalName();
100      assertEquals("nodegetlocalname03_localElemName", "elem", localElemName);
101      assertEquals("nodegetlocalname03_localQElemName", "qelem", localQElemName);
102      assertEquals("nodegetlocalname03_localAttrName", "attr", localAttrName);
103      assertEquals("nodegetlocalname03_localQAttrName", "qattr", localQAttrName);
104      }
105
106}
107
108