Home | History | Annotate | Download | only in core
      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 org.w3c.domts.level2.core;
     24 
     25 import org.w3c.dom.*;
     26 
     27 
     28 import org.w3c.domts.DOMTestCase;
     29 import org.w3c.domts.DOMTestDocumentBuilderFactory;
     30 
     31 
     32 
     33 /**
     34  *     The "importNode(importedNode,deep)" method for a
     35  *    Document should import the given importedNode into that Document.
     36  *    The importedNode is of type Element.
     37  *
     38  *    Retrieve element "emp:address" from staffNS.xml document.
     39  *    Invoke method importNode(importedNode,deep) on this document
     40  *    with importedNode being the element from above and deep is false.
     41  *    Method should return an element node whose name matches "emp:address"
     42  *    and whose children are not imported. The returned node should
     43  *    belong to this document whose systemId is "staff.dtd"
     44 * @author NIST
     45 * @author Mary Brady
     46 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode">http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode</a>
     47 */
     48 public final class importNode05 extends DOMTestCase {
     49 
     50    /**
     51     * Constructor.
     52     * @param factory document factory, may not be null
     53     * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
     54     */
     55    public importNode05(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
     56       super(factory);
     57 
     58     //
     59     //   check if loaded documents are supported for content type
     60     //
     61     String contentType = getContentType();
     62     preload(contentType, "staffNS", true);
     63     preload(contentType, "staffNS", true);
     64     }
     65 
     66    /**
     67     * Runs the test case.
     68     * @throws Throwable Any uncaught exception causes test to fail
     69     */
     70    public void runTest() throws Throwable {
     71       Document doc;
     72       Document aNewDoc;
     73       Element element;
     74       Node aNode;
     75       boolean hasChild;
     76       Document ownerDocument;
     77       DocumentType docType;
     78       String system;
     79       String name;
     80       NodeList addresses;
     81       doc = (Document) load("staffNS", true);
     82       aNewDoc = (Document) load("staffNS", true);
     83       addresses = aNewDoc.getElementsByTagName("emp:address");
     84       element = (Element) addresses.item(0);
     85       assertNotNull("empAddressNotNull", element);
     86       aNode = doc.importNode(element, false);
     87       hasChild = aNode.hasChildNodes();
     88       assertFalse("hasChild", hasChild);
     89 ownerDocument = aNode.getOwnerDocument();
     90       docType = ownerDocument.getDoctype();
     91       system = docType.getSystemId();
     92       assertURIEquals("dtdSystemId", null, null, null, "staffNS.dtd", null, null, null, null, system);
     93 name = aNode.getNodeName();
     94       assertEquals("nodeName", "emp:address", name);
     95       }
     96    /**
     97     *  Gets URI that identifies the test.
     98     *  @return uri identifier of test
     99     */
    100    public String getTargetURI() {
    101       return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/importNode05";
    102    }
    103    /**
    104     * Runs this test from the command line.
    105     * @param args command line arguments
    106     */
    107    public static void main(final String[] args) {
    108         DOMTestCase.doMain(importNode05.class, args);
    109    }
    110 }
    111 
    112