1package tests.org.w3c.dom;
2
3import dalvik.annotation.TestTargets;
4import dalvik.annotation.TestLevel;
5import dalvik.annotation.TestTargetNew;
6import dalvik.annotation.TestTargetClass;
7
8import org.w3c.dom.DocumentType;
9import org.w3c.dom.Document;
10import org.w3c.dom.DOMImplementation;
11
12import javax.xml.parsers.DocumentBuilder;
13
14/**
15 * The method getInternalSubset() returns the internal subset as a string.
16 *
17 * Create a new DocumentType node with null values for publicId and systemId.
18 * Verify that its internal subset is null.
19 *
20 * @author IBM
21 * @author Neil Delima
22 * @see <a
23 *      href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-internalSubset">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-internalSubset</a>
24 * @see <a
25 *      href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=259">http://www.w3.org/Bugs/Public/show_bug.cgi?id=259</a>
26 */
27@TestTargetClass(DocumentType.class)
28public final class DocumentTypeInternalSubset extends DOMTestCase {
29
30    DOMDocumentBuilderFactory factory;
31
32    DocumentBuilder builder;
33
34    protected void setUp() throws Exception {
35        super.setUp();
36        try {
37            factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
38                    .getConfiguration1());
39            builder = factory.getBuilder();
40        } catch (Exception e) {
41            fail("Unexpected exception" + e.getMessage());
42        }
43    }
44
45    protected void tearDown() throws Exception {
46        factory = null;
47        builder = null;
48        super.tearDown();
49    }
50
51    /**
52     * Runs the test case.
53     *
54     * @throws Throwable
55     *             Any uncaught exception causes test to fail
56     */
57    @TestTargetNew(
58        level = TestLevel.PARTIAL,
59        notes = "Doesn't check positive case.",
60        method = "getInternalSubset",
61        args = {}
62    )
63    public void testGetInternalSubset() throws Throwable {
64        Document doc;
65        DocumentType docType;
66        DOMImplementation domImpl;
67        String internal;
68        String nullNS = null;
69
70        doc = (Document) load("staffNS", builder);
71        domImpl = doc.getImplementation();
72        docType = domImpl.createDocumentType("l2:root", nullNS, nullNS);
73        internal = docType.getInternalSubset();
74        assertNull("internalSubsetNull", internal);
75    }
76}
77