Save This Page
Home » dom4j-1.6.1 » org.dom4j.io » [javadoc | source]
org.dom4j.io
public class: DTDTest [javadoc | source]
java.lang.Object
   junit.framework.TestCase
      org.dom4j.AbstractTestCase
         org.dom4j.io.DTDTest
Tests the DocType functionality.

Incorporated additional test cases for optional processing of the internal and external DTD subsets. The "external" and "mixed" tests both fail due to a reported bug. See http://tinyurl.com/4dzyq

Nested Class Summary:
protected static class  DTDTest.MyEntityResolver  Provides a resolver for the local test DTD resource. 
Field Summary
protected static final  String DTD_PUBLICID    The PUBLIC identifier, which is -//dom4j//DTD sample, for the external entity providing DTD for tests. 
protected static final  String DTD_SYSTEM_ID    The SYSTEM identifier, which is sample.dtd, for the external entity providing DTD for tests. 
Fields inherited from org.dom4j.AbstractTestCase:
document
Method from org.dom4j.io.DTDTest Summary:
assertSameDTDSubset,   assertSameDecl,   assertSameDecl,   assertSameDecl,   assertSameDecl,   assertSameDocumentType,   getExternalDeclarations,   getInternalDeclarations,   main,   readDocument,   testExternalDTDSubset,   testInternalDTDSubset,   testMixedDTDSubset
Methods from org.dom4j.AbstractTestCase:
assertDocumentsEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqual,   assertNodesEqualContent,   getDocument,   getDocument,   getDocument,   getFile,   getRootElement,   log,   setUp
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.dom4j.io.DTDTest Detail:
 protected  void assertSameDTDSubset(String txt,
    List expected,
    List actual) 
    Test helper method compares an expected set of DTD declarations with an actual set of DTD declarations. This method should be invoked seperately for the internal DTD subset and the external DTD subset. The declarations must occur in their logical ordering. See Lexical Handler for conformance criteria.
 public  void assertSameDecl(AttributeDecl expected,
    AttributeDecl actual) 
    Test helper method compares an expected and an actual AttributeDecl .
 protected  void assertSameDecl(ElementDecl expected,
    ElementDecl actual) 
    Test helper method compares an expected and an actual ElementDecl .
 protected  void assertSameDecl(InternalEntityDecl expected,
    InternalEntityDecl actual) 
 protected  void assertSameDecl(ExternalEntityDecl expected,
    ExternalEntityDecl actual) 
 protected  void assertSameDocumentType(DocumentType expected,
    DocumentType actual) 
    Test helper method compares the expected and actual DocumentType objects, including their internal and external DTD subsets.

 protected List getExternalDeclarations() 
    Test helper method returns a List of DTD declarations that represents the expected external DTD subset (for the tests that use an external DTD subset).
 protected List getInternalDeclarations() 
    Test helper method returns a List of DTD declarations that represents the expected internal DTD subset (for the tests that use an internal DTD subset).

    Note: The declarations returned by this method MUST agree those actually declared in #XML_INTERNAL_FILE and #XML_MIXED .

 public static  void main(String[] args) 
 protected Document readDocument(String resourceName,
    boolean includeInternal,
    boolean includeExternal) throws Exception 
    Helper method reads a local resource and parses it as an XML document. The internal and external DTD subsets are optionally retained by the parser and exposed via the DocumentType object on the returned Document . The parser is configured with an EntityResolver that knows how to find the local resource identified by #DTD_FILE whose SYSTEM identifier is given by #DTD_SYSTEM_ID .
 public  void testExternalDTDSubset() 
    Test verifies correct identification of the external DTD subset and correct non-presence of the internal DTD subset.
 public  void testInternalDTDSubset() throws Exception 
    Test verifies correct identification of the internal DTD subset and correct non-presence of the external DTD subset.
 public  void testMixedDTDSubset() 
    Test verifies correct identification of the internal and external DTD subsets.