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
22package tests.org.w3c.dom;
23
24import org.w3c.dom.Document;
25import org.w3c.dom.Element;
26
27import javax.xml.parsers.DocumentBuilder;
28
29/**
30 * The "getElementById(elementId)" method for a Document should return an
31 * element whose ID matches elementId.
32 *
33 * Invoke method getElementById(elementId) on this document with elementId
34 * equals "CANADA". Method should return an element whose tag name is
35 * "emp:address".
36 *
37 * @author NIST
38 * @author Mary Brady
39 * @see <a
40 *      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>
41 * @see <a
42 *      href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=383">http://www.w3.org/Bugs/Public/show_bug.cgi?id=383</a>
43 */
44public final class GetElementById extends DOMTestCase {
45
46    DOMDocumentBuilderFactory factory;
47
48    DocumentBuilder builder;
49
50    protected void setUp() throws Exception {
51        super.setUp();
52        try {
53            factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
54                    .getConfiguration1());
55            builder = factory.getBuilder();
56        } catch (Exception e) {
57            fail("Unexpected exception" + e.getMessage());
58        }
59    }
60
61    protected void tearDown() throws Exception {
62        factory = null;
63        builder = null;
64        super.tearDown();
65    }
66
67    /**
68     * Runs the test case.
69     *
70     * @throws Throwable
71     *             Any uncaught exception causes test to fail
72     */
73// Assumes validation.
74//    public void testGetElementById1() throws Throwable {
75//        Document doc;
76//        Element element;
77//        String tagname;
78//        doc = (Document) load("staffNS", builder);
79//        element = doc.getElementById("CANADA");
80//        tagname = element.getTagName();
81//        assertEquals("throw_Equals", "emp:address", tagname);
82//    }
83    public void testGetElementById2() throws Throwable {
84        Document doc;
85        Element element;
86        doc = (Document) load("staffNS", builder);
87        element = doc.getElementById("Cancun");
88        assertNull("throw_Null", element);
89    }
90}
91