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-2003 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.Document;
31import org.w3c.dom.DocumentType;
32import org.w3c.dom.DOMImplementation;
33
34import javax.xml.parsers.DocumentBuilder;
35
36
37
38/**
39 *     The method getInternalSubset() returns the public identifier of the external subset.
40 *
41 *     Create a new DocumentType node with the value "PUB" for its publicId.
42 *     Check the value of the publicId attribute using getPublicId().
43* @author IBM
44* @author Neil Delima
45* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-publicId">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-publicId</a>
46* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=259">http://www.w3.org/Bugs/Public/show_bug.cgi?id=259</a>
47*/
48@TestTargetClass(DocumentType.class)
49public final class DocumentTypePublicId extends DOMTestCase {
50
51    DOMDocumentBuilderFactory factory;
52
53    DocumentBuilder builder;
54
55    protected void setUp() throws Exception {
56        super.setUp();
57        try {
58            factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
59                    .getConfiguration1());
60            builder = factory.getBuilder();
61        } catch (Exception e) {
62            fail("Unexpected exception" + e.getMessage());
63        }
64    }
65
66    protected void tearDown() throws Exception {
67        factory = null;
68        builder = null;
69        super.tearDown();
70    }
71
72   /**
73    * Runs the test case.
74    * @throws Throwable Any uncaught exception causes test to fail
75    */
76    @TestTargetNew(
77        level = TestLevel.COMPLETE,
78        notes = "",
79        method = "getPublicId",
80        args = {}
81    )
82   public void testGetPublicId() throws Throwable {
83      Document doc;
84      DocumentType docType;
85      DOMImplementation domImpl;
86      String publicId;
87      String nullNS = null;
88
89      doc = (Document) load("staffNS", builder);
90      domImpl = doc.getImplementation();
91      docType = domImpl.createDocumentType("l2:root", "PUB", nullNS);
92      publicId = docType.getPublicId();
93      assertEquals("documenttypepublicid01", "PUB", publicId);
94      }
95
96}
97
98