Home | History | Annotate | Download | only in dom
      1 package tests.org.w3c.dom;
      2 
      3 import org.w3c.dom.DocumentType;
      4 import org.w3c.dom.Document;
      5 import org.w3c.dom.DOMImplementation;
      6 
      7 import javax.xml.parsers.DocumentBuilder;
      8 
      9 /**
     10  * The method getInternalSubset() returns the internal subset as a string.
     11  *
     12  * Create a new DocumentType node with null values for publicId and systemId.
     13  * Verify that its internal subset is null.
     14  *
     15  * @author IBM
     16  * @author Neil Delima
     17  * @see <a
     18  *      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>
     19  * @see <a
     20  *      href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=259">http://www.w3.org/Bugs/Public/show_bug.cgi?id=259</a>
     21  */
     22 public final class DocumentTypeInternalSubset extends DOMTestCase {
     23 
     24     DOMDocumentBuilderFactory factory;
     25 
     26     DocumentBuilder builder;
     27 
     28     protected void setUp() throws Exception {
     29         super.setUp();
     30         try {
     31             factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
     32                     .getConfiguration1());
     33             builder = factory.getBuilder();
     34         } catch (Exception e) {
     35             fail("Unexpected exception" + e.getMessage());
     36         }
     37     }
     38 
     39     protected void tearDown() throws Exception {
     40         factory = null;
     41         builder = null;
     42         super.tearDown();
     43     }
     44 
     45     /**
     46      * Runs the test case.
     47      *
     48      * @throws Throwable
     49      *             Any uncaught exception causes test to fail
     50      */
     51     public void testGetInternalSubset() throws Throwable {
     52         Document doc;
     53         DocumentType docType;
     54         DOMImplementation domImpl;
     55         String internal;
     56         String nullNS = null;
     57 
     58         doc = (Document) load("staffNS", builder);
     59         domImpl = doc.getImplementation();
     60         docType = domImpl.createDocumentType("l2:root", nullNS, nullNS);
     61         internal = docType.getInternalSubset();
     62         assertNull("internalSubsetNull", internal);
     63     }
     64 }
     65