1 package tests.org.w3c.dom;
3 import dalvik.annotation.TestTargets;
4 import dalvik.annotation.TestLevel;
5 import dalvik.annotation.TestTargetNew;
6 import dalvik.annotation.TestTargetClass;
8 import org.w3c.dom.Document;
9 import org.w3c.dom.Element;
11 import javax.xml.parsers.DocumentBuilder;
14 * The method getElementById returns the element whose ID is given by elementId.
15 * If not such element exists, returns null.
17 * Invoke the getElementById method on this Document object with an invalid
18 * elementId. This should return a null element.
23 * href="http://www.w3.org/TR/DOM-Level-2-Core/core">http://www.w3.org/TR/DOM-Level-2-Core/core</a>
25 * href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBId">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-getElBId</a>
27 @TestTargetClass(Document.class)
28 public final class DocumentGeteEementById extends DOMTestCase {
30 DOMDocumentBuilderFactory factory;
32 DocumentBuilder builder;
34 protected void setUp() throws Exception {
37 factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
38 .getConfiguration1());
39 builder = factory.getBuilder();
40 } catch (Exception e) {
41 fail("Unexpected exception" + e.getMessage());
45 protected void tearDown() throws Exception {
55 * Any uncaught exception causes test to fail
58 level = TestLevel.PARTIAL,
59 notes = "Doesn't verify getElementById method for existent element.",
60 method = "getElementById",
61 args = {java.lang.String.class}
63 public void testGetElementById() throws Throwable {
66 String elementId = "---";
67 doc = (Document) load("staffNS", builder);
68 element = doc.getElementById(elementId);
69 assertNull("documentgetelementbyid01", element);