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 | |
| 33 | import javax.xml.parsers.DocumentBuilder; |
| 34 | |
| 35 | /** |
| 36 | * The "getPublicId()" method of a documenttype node contains |
| 37 | * the public identifier associated with the external subset. |
| 38 | * |
| 39 | * Retrieve the documenttype. |
| 40 | * Apply the "getPublicId()" method. The string "STAFF" should be |
| 41 | * returned. |
| 42 | * @author NIST |
| 43 | * @author Mary Brady |
| 44 | * @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> |
| 45 | */ |
| 46 | @TestTargetClass(DocumentType.class) |
| 47 | public final class PublicId extends DOMTestCase { |
| 48 | |
| 49 | DOMDocumentBuilderFactory factory; |
| 50 | |
| 51 | DocumentBuilder builder; |
| 52 | |
| 53 | protected void setUp() throws Exception { |
| 54 | super.setUp(); |
| 55 | try { |
| 56 | factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory |
| 57 | .getConfiguration1()); |
| 58 | builder = factory.getBuilder(); |
| 59 | } catch (Exception e) { |
| 60 | fail("Unexpected exception" + e.getMessage()); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | protected void tearDown() throws Exception { |
| 65 | factory = null; |
| 66 | builder = null; |
| 67 | super.tearDown(); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Runs the test case. |
| 72 | * @throws Throwable Any uncaught exception causes test to fail |
| 73 | */ |
| 74 | @TestTargetNew( |
| 75 | level = TestLevel.COMPLETE, |
| 76 | notes = "", |
| 77 | method = "getPublicId", |
| 78 | args = {} |
| 79 | ) |
| 80 | public void testGetPublicId() throws Throwable { |
| 81 | Document doc; |
| 82 | DocumentType docType; |
| 83 | String publicId; |
| 84 | doc = (Document) load("staffNS", builder); |
| 85 | docType = doc.getDoctype(); |
| 86 | publicId = docType.getPublicId(); |
| 87 | assertEquals("throw_Equals", "STAFF", publicId); |
| 88 | } |
| 89 | |
| 90 | } |
| 91 | |