The Android Open Source Project | adc854b | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | This Java source file was generated by test-to-java.xsl |
| 4 | and is a derived work from the source document. |
| 5 | The source document contained the following notice: |
| 6 | |
| 7 | |
| 8 | |
| 9 | Copyright (c) 2001 World Wide Web Consortium, |
| 10 | (Massachusetts Institute of Technology, Institut National de |
| 11 | Recherche en Informatique et en Automatique, Keio University). All |
| 12 | Rights Reserved. This program is distributed under the W3C's Software |
| 13 | Intellectual Property License. This program is distributed in the |
| 14 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
| 15 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 16 | PURPOSE. |
| 17 | |
| 18 | See W3C License http://www.w3.org/Consortium/Legal/ for more details. |
| 19 | |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | package tests.org.w3c.dom; |
| 24 | |
| 25 | import dalvik.annotation.TestTargets; |
| 26 | import dalvik.annotation.TestLevel; |
| 27 | import dalvik.annotation.TestTargetNew; |
| 28 | import dalvik.annotation.TestTargetClass; |
| 29 | |
| 30 | import org.w3c.dom.DocumentType; |
| 31 | import org.w3c.dom.Document; |
| 32 | import org.w3c.dom.DOMImplementation; |
| 33 | |
| 34 | import javax.xml.parsers.DocumentBuilder; |
| 35 | |
| 36 | /** |
| 37 | * The method getInternalSubset() returns the public identifier of the external subset. |
| 38 | * |
| 39 | * Create a new DocumentType node with the value "SYS" for its systemId and PUB for |
| 40 | * its publicId. Check the value of the systemId and pbulicId attributes. |
| 41 | * @author IBM |
| 42 | * @author Neil Delima |
| 43 | * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-systemId">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-Core-DocType-systemId</a> |
| 44 | */ |
| 45 | @TestTargetClass(DocumentType.class) |
| 46 | public final class DocumentTypeSystemId extends DOMTestCase { |
| 47 | DOMDocumentBuilderFactory factory; |
| 48 | |
| 49 | DocumentBuilder builder; |
| 50 | |
| 51 | protected void setUp() throws Exception { |
| 52 | super.setUp(); |
| 53 | try { |
| 54 | factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory |
| 55 | .getConfiguration1()); |
| 56 | builder = factory.getBuilder(); |
| 57 | } catch (Exception e) { |
| 58 | fail("Unexpected exception" + e.getMessage()); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | protected void tearDown() throws Exception { |
| 63 | factory = null; |
| 64 | builder = null; |
| 65 | super.tearDown(); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | /** |
| 70 | * Runs the test case. |
| 71 | * @throws Throwable Any uncaught exception causes test to fail |
| 72 | */ |
| 73 | @TestTargetNew( |
| 74 | level = TestLevel.COMPLETE, |
| 75 | notes = "", |
| 76 | method = "getSystemId", |
| 77 | args = {} |
| 78 | ) |
| 79 | public void testGetSystemId() throws Throwable { |
| 80 | Document doc; |
| 81 | DocumentType docType; |
| 82 | DOMImplementation domImpl; |
| 83 | String publicId; |
| 84 | String systemId; |
| 85 | doc = (Document) load("staffNS", builder); |
| 86 | domImpl = doc.getImplementation(); |
| 87 | docType = domImpl.createDocumentType("l2:root", "PUB", "SYS"); |
| 88 | publicId = docType.getPublicId(); |
| 89 | systemId = docType.getSystemId(); |
| 90 | assertEquals("documenttypepublicid01", "PUB", publicId); |
| 91 | assertEquals("documenttypesystemid01", "SYS", systemId); |
| 92 | } |
| 93 | |
| 94 | } |
| 95 | |