OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / luni / src / test / java / tests / org / w3c / dom / GetElementById.java
1 /*
2  This Java source file was generated by test-to-java.xsl
3  and is a derived work from the source document.
4  The source document contained the following notice:
5
6
7
8  Copyright (c) 2001-2003 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
17  See W3C License http://www.w3.org/Consortium/Legal/ for more details.
18
19
20  */
21
22 package tests.org.w3c.dom;
23
24 import dalvik.annotation.TestTargets;
25 import dalvik.annotation.TestLevel;
26 import dalvik.annotation.TestTargetNew;
27 import dalvik.annotation.TestTargetClass;
28
29 import org.w3c.dom.Document;
30 import org.w3c.dom.Element;
31
32 import javax.xml.parsers.DocumentBuilder;
33
34 /**
35  * The "getElementById(elementId)" method for a Document should return an
36  * element whose ID matches elementId.
37  *
38  * Invoke method getElementById(elementId) on this document with elementId
39  * equals "CANADA". Method should return an element whose tag name is
40  * "emp:address".
41  *
42  * @author NIST
43  * @author Mary Brady
44  * @see <a
45  *      href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-104682815">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-104682815</a>
46  * @see <a
47  *      href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=383">http://www.w3.org/Bugs/Public/show_bug.cgi?id=383</a>
48  */
49 @TestTargetClass(Document.class)
50 public final class GetElementById extends DOMTestCase {
51
52     DOMDocumentBuilderFactory factory;
53
54     DocumentBuilder builder;
55
56     protected void setUp() throws Exception {
57         super.setUp();
58         try {
59             factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
60                     .getConfiguration1());
61             builder = factory.getBuilder();
62         } catch (Exception e) {
63             fail("Unexpected exception" + e.getMessage());
64         }
65     }
66
67     protected void tearDown() throws Exception {
68         factory = null;
69         builder = null;
70         super.tearDown();
71     }
72
73     /**
74      * Runs the test case.
75      *
76      * @throws Throwable
77      *             Any uncaught exception causes test to fail
78      */
79 // Assumes validation.
80 //    public void testGetElementById1() throws Throwable {
81 //        Document doc;
82 //        Element element;
83 //        String tagname;
84 //        doc = (Document) load("staffNS", builder);
85 //        element = doc.getElementById("CANADA");
86 //        tagname = element.getTagName();
87 //        assertEquals("throw_Equals", "emp:address", tagname);
88 //    }
89     @TestTargetNew(
90         level = TestLevel.PARTIAL,
91         notes = "Doesn't verify getElementById method for existent element.",
92         method = "getElementById",
93         args = {java.lang.String.class}
94     )
95     public void testGetElementById2() throws Throwable {
96         Document doc;
97         Element element;
98         doc = (Document) load("staffNS", builder);
99         element = doc.getElementById("Cancun");
100         assertNull("throw_Null", element);
101     }
102 }