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