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.Document;
     26 import org.w3c.dom.DocumentType;
     27 
     28 import javax.xml.parsers.DocumentBuilder;
     29 
     30 /**
     31  *     The "getOwnerDocument()" method returns null if the target
     32  *     node itself is a DocumentType which is not used with any document yet.
     33  *
     34  *     Invoke the "getOwnerDocument()" method on the master
     35  *     document.   The DocumentType returned should be null.
     36 * @author NIST
     37 * @author Mary Brady
     38 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#node-ownerDoc">http://www.w3.org/TR/DOM-Level-2-Core/core#node-ownerDoc</a>
     39 */
     40 public final class OwnerDocument extends DOMTestCase {
     41 
     42     DOMDocumentBuilderFactory factory;
     43 
     44     DocumentBuilder builder;
     45 
     46     protected void setUp() throws Exception {
     47         super.setUp();
     48         try {
     49             factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
     50                     .getConfiguration1());
     51             builder = factory.getBuilder();
     52         } catch (Exception e) {
     53             fail("Unexpected exception" + e.getMessage());
     54         }
     55     }
     56 
     57     protected void tearDown() throws Exception {
     58         factory = null;
     59         builder = null;
     60         super.tearDown();
     61     }
     62 
     63    /**
     64     * Runs the test case.
     65     * @throws Throwable Any uncaught exception causes test to fail
     66     */
     67    public void testGetOwnerDocument() throws Throwable {
     68       Document doc;
     69       DocumentType ownerDocument;
     70       doc = (Document) load("staff", builder);
     71       ownerDocument = (DocumentType) doc.getOwnerDocument();
     72       assertNull("throw_Null", ownerDocument);
     73       }
     74 
     75 }
     76 
     77