Home | History | Annotate | Download | only in dom
      1 package tests.org.w3c.dom;
      2 
      3 import dalvik.annotation.TestTargets;
      4 import dalvik.annotation.TestLevel;
      5 import dalvik.annotation.TestTargetNew;
      6 import dalvik.annotation.TestTargetClass;
      7 
      8 import org.w3c.dom.Document;
      9 import org.w3c.dom.Element;
     10 import org.w3c.dom.Node;
     11 import org.w3c.dom.Attr;
     12 import org.w3c.dom.NodeList;
     13 import org.w3c.dom.DOMException;
     14 import org.w3c.dom.DocumentType;
     15 import org.w3c.dom.DOMImplementation;
     16 import org.w3c.dom.DocumentFragment;
     17 import org.w3c.dom.ProcessingInstruction;
     18 
     19 import javax.xml.parsers.DocumentBuilder;
     20 
     21 /**
     22  * The importNode method imports a node from another document to this document.
     23  * The returned node has no parent; (parentNode is null). The source node is not
     24  * altered or removed from the original document but a new copy of the source
     25  * node is created.
     26  *
     27  * Using the method importNode with deep=true, import the attribute, "street" of
     28  * the second element node, from a list of nodes whose local names are "address"
     29  * and namespaceURI "http://www.nist.gov" into the same document. Check the
     30  * parentNode, nodeName, nodeType and nodeValue of the imported node to verify
     31  * if it has been imported correctly.
     32  *
     33  * @author IBM
     34  * @author Neil Delima
     35  * @see <a
     36  *      href="http://www.w3.org/TR/DOM-Level-2-Core/core">http://www.w3.org/TR/DOM-Level-2-Core/core</a>
     37  * @see <a
     38  *      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>
     39  */
     40 @TestTargetClass(Document.class)
     41 public final class DocumentImportNode 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                     .getConfiguration2());
     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      *
     67      * @throws Throwable
     68      *             Any uncaught exception causes test to fail
     69      */
     70 // Assumes validation.
     71 //    public void testImportNode1() throws Throwable {
     72 //        Document doc;
     73 //        Element element;
     74 //        Attr attr;
     75 //        NodeList childList;
     76 //        Node importedAttr;
     77 //        String nodeName;
     78 //        int nodeType;
     79 //        String nodeValue;
     80 //        doc = (Document) load("staffNS", builder);
     81 //        childList = doc
     82 //                .getElementsByTagNameNS("http://www.nist.gov", "address");
     83 //        element = (Element) childList.item(1);
     84 //        attr = element.getAttributeNode("street");
     85 //        importedAttr = doc.importNode(attr, false);
     86 //        nodeName = importedAttr.getNodeName();
     87 //        nodeValue = importedAttr.getNodeValue();
     88 //        nodeType = (int) importedAttr.getNodeType();
     89 //        assertEquals("documentimportnode01_nodeName", "street", nodeName);
     90 //        assertEquals("documentimportnode01_nodeType", 2, nodeType);
     91 //        assertEquals("documentimportnode01_nodeValue", "Yes", nodeValue);
     92 //    }
     93     @TestTargetNew(
     94         level = TestLevel.PARTIAL_COMPLETE,
     95         notes = "Doesn't verify DOMException exception.",
     96         method = "importNode",
     97         args = {org.w3c.dom.Node.class, boolean.class}
     98     )
     99     public void testImportNode2() throws Throwable {
    100         Document doc;
    101         Document docImported;
    102         Element element;
    103         Attr attr;
    104         Node importedAttr;
    105         String nodeName;
    106         int nodeType;
    107         String nodeValue;
    108         NodeList addresses;
    109         Node attrsParent;
    110         doc = (Document) load("staffNS", builder);
    111         docImported = (Document) load("staff", builder);
    112         addresses = doc
    113                 .getElementsByTagNameNS("http://www.nist.gov", "address");
    114         element = (Element) addresses.item(1);
    115         attr = element.getAttributeNodeNS("http://www.nist.gov", "zone");
    116         importedAttr = docImported.importNode(attr, false);
    117         nodeName = importedAttr.getNodeName();
    118         nodeType = (int) importedAttr.getNodeType();
    119         nodeValue = importedAttr.getNodeValue();
    120         attrsParent = importedAttr.getParentNode();
    121         assertNull("documentimportnode02_parentNull", attrsParent);
    122         assertEquals("documentimportnode02_nodeName", "emp:zone", nodeName);
    123         assertEquals("documentimportnode02_nodeType", 2, nodeType);
    124         assertEquals("documentimportnode02_nodeValue", "CANADA", nodeValue);
    125     }
    126 
    127 // Assumes validation.
    128 //    public void testImportNode3() throws Throwable {
    129 //        Document doc;
    130 //        Element element;
    131 //        Attr attr;
    132 //        NodeList childList;
    133 //        Node importedAttr;
    134 //        String nodeName;
    135 //        int nodeType;
    136 //        String nodeValue;
    137 //        doc = (Document) load("staffNS", builder);
    138 //        childList = doc.getElementsByTagNameNS("http://www.nist.gov",
    139 //                "employee");
    140 //        element = (Element) childList.item(1);
    141 //        attr = element.getAttributeNode("defaultAttr");
    142 //        importedAttr = doc.importNode(attr, false);
    143 //        nodeName = importedAttr.getNodeName();
    144 //        nodeValue = importedAttr.getNodeValue();
    145 //        nodeType = (int) importedAttr.getNodeType();
    146 //        assertEquals("documentimportnode03_nodeName", "defaultAttr", nodeName);
    147 //        assertEquals("documentimportnode03_nodeType", 2, nodeType);
    148 //        assertEquals("documentimportnode03_nodeValue", "defaultVal", nodeValue);
    149 //    }
    150 
    151 // Assumes validation.
    152 //    public void testImportNode4() throws Throwable {
    153 //        Document doc;
    154 //        Document newDoc;
    155 //        DocumentType docType = null;
    156 //
    157 //        DOMImplementation domImpl;
    158 //        Element element;
    159 //        Attr attr;
    160 //        NodeList childList;
    161 //        Node importedAttr;
    162 //        String nodeName;
    163 //        int nodeType;
    164 //        String nodeValue;
    165 //        doc = (Document) load("staffNS", builder);
    166 //        domImpl = doc.getImplementation();
    167 //        newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test",
    168 //                "l2:root", docType);
    169 //        childList = doc.getElementsByTagNameNS("http://www.nist.gov",
    170 //                "employee");
    171 //        element = (Element) childList.item(1);
    172 //        attr = element.getAttributeNode("defaultAttr");
    173 //        importedAttr = newDoc.importNode(attr, true);
    174 //        nodeName = importedAttr.getNodeName();
    175 //        nodeValue = importedAttr.getNodeValue();
    176 //        nodeType = (int) importedAttr.getNodeType();
    177 //        assertEquals("documentimportnode04_nodeName", "defaultAttr", nodeName);
    178 //        assertEquals("documentimportnode04_nodeType", 2, nodeType);
    179 //        assertEquals("documentimportnode04_nodeValue", "defaultVal", nodeValue);
    180 //    }
    181     @TestTargetNew(
    182         level = TestLevel.PARTIAL_COMPLETE,
    183         notes = "Doesn't verify DOMException exception.",
    184         method = "importNode",
    185         args = {org.w3c.dom.Node.class, boolean.class}
    186     )
    187     public void testImportNode5() throws Throwable {
    188         Document doc;
    189         Document docImported;
    190         Attr attr;
    191         Node importedAttr;
    192         String nodeName;
    193         int nodeType;
    194         String nodeValue;
    195         String namespaceURI;
    196         doc = (Document) load("staffNS", builder);
    197         docImported = (Document) load("staff", builder);
    198         attr = doc.createAttributeNS("http://www.w3.org/DOM/Test", "a_:b0");
    199         importedAttr = docImported.importNode(attr, false);
    200         nodeName = importedAttr.getNodeName();
    201         nodeValue = importedAttr.getNodeValue();
    202         nodeType = (int) importedAttr.getNodeType();
    203         namespaceURI = importedAttr.getNamespaceURI();
    204         assertEquals("documentimportnode05_nodeName", "a_:b0", nodeName);
    205         assertEquals("documentimportnode05_nodeType", 2, nodeType);
    206         assertEquals("documentimportnode05_nodeValue", "", nodeValue);
    207         assertEquals("documentimportnode05_namespaceURI",
    208                 "http://www.w3.org/DOM/Test", namespaceURI);
    209     }
    210     @TestTargetNew(
    211         level = TestLevel.PARTIAL_COMPLETE,
    212         notes = "Verifies that importNode method throws DOMException with NOT_SUPPORTED_ERR code.",
    213         method = "importNode",
    214         args = {org.w3c.dom.Node.class, boolean.class}
    215     )
    216     public void testImportNode6() throws Throwable {
    217         Document doc;
    218 
    219         doc = (Document) load("staffNS", builder);
    220 
    221         {
    222             boolean success = false;
    223             try {
    224                 doc.importNode(doc, false);
    225             } catch (DOMException ex) {
    226                 success = (ex.code == DOMException.NOT_SUPPORTED_ERR);
    227             }
    228             assertTrue("throw_NOT_SUPPORTED_ERR", success);
    229         }
    230     }
    231     @TestTargetNew(
    232         level = TestLevel.PARTIAL_COMPLETE,
    233         notes = "Verifies that importNode method throws DOMException with NOT_SUPPORTED_ERR code.",
    234         method = "importNode",
    235         args = {org.w3c.dom.Node.class, boolean.class}
    236     )
    237     public void testImportNode7() throws Throwable {
    238         Document doc;
    239 
    240         DocumentType docType;
    241         doc = (Document) load("staffNS", builder);
    242         docType = doc.getDoctype();
    243 
    244         {
    245             boolean success = false;
    246             try {
    247                 doc.importNode(docType, true);
    248             } catch (DOMException ex) {
    249                 success = (ex.code == DOMException.NOT_SUPPORTED_ERR);
    250             }
    251             assertTrue("throw_NOT_SUPPORTED_ERR", success);
    252         }
    253     }
    254     @TestTargetNew(
    255         level = TestLevel.PARTIAL_COMPLETE,
    256         notes = "Verifies that importNode method throws DOMException with NOT_SUPPORTED_ERR code.",
    257         method = "importNode",
    258         args = {org.w3c.dom.Node.class, boolean.class}
    259     )
    260     public void testImportNode8() throws Throwable {
    261         Document doc;
    262 
    263         DocumentType docType;
    264         DOMImplementation domImpl;
    265         String nullNS = null;
    266 
    267         doc = (Document) load("staffNS", builder);
    268         domImpl = doc.getImplementation();
    269         docType = domImpl.createDocumentType("test:root", nullNS, nullNS);
    270 
    271         {
    272             boolean success = false;
    273             try {
    274                 doc.importNode(docType, true);
    275             } catch (DOMException ex) {
    276                 success = (ex.code == DOMException.NOT_SUPPORTED_ERR);
    277             }
    278             assertTrue("throw_NOT_SUPPORTED_ERR", success);
    279         }
    280     }
    281     @TestTargetNew(
    282         level = TestLevel.PARTIAL_COMPLETE,
    283         notes = "Doesn't verify DOMException exception.",
    284         method = "importNode",
    285         args = {org.w3c.dom.Node.class, boolean.class}
    286     )
    287     public void testImportNode9() throws Throwable {
    288         Document doc;
    289         DocumentFragment docFragment;
    290         NodeList childList;
    291         boolean success;
    292         Node addressNode;
    293 
    294         Node importedDocFrag;
    295         doc = (Document) load("staffNS", builder);
    296         docFragment = doc.createDocumentFragment();
    297         childList = doc.getElementsByTagNameNS("*", "address");
    298         addressNode = childList.item(0);
    299         docFragment.appendChild(addressNode);
    300         importedDocFrag = doc.importNode(docFragment, false);
    301         success = importedDocFrag.hasChildNodes();
    302         assertFalse("documentimportnode09", success);
    303     }
    304     @TestTargetNew(
    305         level = TestLevel.PARTIAL_COMPLETE,
    306         notes = "Verifies positive functionality; doesn't verify DOMException exceptions.",
    307         method = "importNode",
    308         args = {org.w3c.dom.Node.class, boolean.class}
    309     )
    310     public void testImportNode10() throws Throwable {
    311         Document doc;
    312         DocumentFragment docFragment;
    313         NodeList childList;
    314         boolean success;
    315         Node addressNode;
    316 
    317         Node importedDocFrag;
    318         doc = (Document) load("staffNS", builder);
    319         docFragment = doc.createDocumentFragment();
    320         childList = doc.getElementsByTagNameNS("*", "address");
    321         addressNode = childList.item(0);
    322         docFragment.appendChild(addressNode);
    323         importedDocFrag = doc.importNode(docFragment, true);
    324         success = importedDocFrag.hasChildNodes();
    325         assertTrue("documentimportnode10", success);
    326     }
    327     @TestTargetNew(
    328         level = TestLevel.PARTIAL_COMPLETE,
    329         notes = "Doesn't verify DOMException exception.",
    330         method = "importNode",
    331         args = {org.w3c.dom.Node.class, boolean.class}
    332     )
    333     public void testImportNode11() throws Throwable {
    334         Document doc;
    335         Element docElement;
    336         Node imported;
    337         boolean success;
    338         String nodeNameOrig;
    339         String nodeNameImported;
    340         doc = (Document) load("staffNS", builder);
    341         docElement = doc.getDocumentElement();
    342         imported = doc.importNode(docElement, false);
    343         success = imported.hasChildNodes();
    344         assertFalse("documentimportnode11", success);
    345         nodeNameImported = imported.getNodeName();
    346         nodeNameOrig = docElement.getNodeName();
    347         assertEquals("documentimportnode11_NodeName", nodeNameImported,
    348                 nodeNameOrig);
    349     }
    350     @TestTargetNew(
    351         level = TestLevel.PARTIAL_COMPLETE,
    352         notes = "Doesn't verify DOMException exception.",
    353         method = "importNode",
    354         args = {org.w3c.dom.Node.class, boolean.class}
    355     )
    356     public void testImportNode12() throws Throwable {
    357         Document doc;
    358         NodeList childList;
    359         Node imported;
    360         Node addressElem;
    361         NodeList addressElemChildren;
    362         NodeList importedChildren;
    363         int addressElemLen;
    364         int importedLen;
    365         doc = (Document) load("staffNS", builder);
    366         childList = doc.getElementsByTagNameNS("*", "address");
    367         addressElem = childList.item(0);
    368         imported = doc.importNode(addressElem, true);
    369         addressElemChildren = addressElem.getChildNodes();
    370         importedChildren = imported.getChildNodes();
    371         addressElemLen = (int) addressElemChildren.getLength();
    372         importedLen = (int) importedChildren.getLength();
    373         assertEquals("documentimportnode12", importedLen, addressElemLen);
    374     }
    375     @TestTargetNew(
    376         level = TestLevel.PARTIAL_COMPLETE,
    377         notes = "Doesn't verify DOMException exception.",
    378         method = "importNode",
    379         args = {org.w3c.dom.Node.class, boolean.class}
    380     )
    381     public void testImportNode13() throws Throwable {
    382         Document doc;
    383         NodeList childList;
    384         Node imported;
    385         NodeList importedList;
    386         Node employeeElem;
    387         int importedLen;
    388         doc = (Document) load("staffNS", builder);
    389         childList = doc.getElementsByTagNameNS("*", "employee");
    390         employeeElem = childList.item(0);
    391         imported = doc.importNode(employeeElem, false);
    392         importedList = imported.getChildNodes();
    393         importedLen = (int) importedList.getLength();
    394         assertEquals("documentimportnode13", 0, importedLen);
    395     }
    396 
    397 // Assumes validation.
    398 //    public void testImportNode14() throws Throwable {
    399 //        Document doc;
    400 //        Document newDoc;
    401 //        DOMImplementation domImpl;
    402 //        DocumentType nullDocType = null;
    403 //
    404 //        NodeList childList;
    405 //        Node imported;
    406 //        Node employeeElem;
    407 //        Attr attrNode;
    408 //        String attrValue;
    409 //        String nullNS = null;
    410 //
    411 //        doc = (Document) load("staffNS", builder);
    412 //        childList = doc.getElementsByTagNameNS("*", "employee");
    413 //        employeeElem = childList.item(3);
    414 //        domImpl = builder.getDOMImplementation();
    415 //        newDoc = domImpl.createDocument(nullNS, "staff", nullDocType);
    416 //        imported = newDoc.importNode(employeeElem, true);
    417 //        attrNode = ((Element) /* Node */imported).getAttributeNodeNS(nullNS,
    418 //                "defaultAttr");
    419 //        assertNull("defaultAttrNotImported", attrNode);
    420 //        attrValue = ((Element) /* Node */imported).getAttributeNS(
    421 //                "http://www.w3.org/2000/xmlns/", "emp");
    422 //        assertEquals("explicitAttrImported", "http://www.nist.gov", attrValue);
    423 //    }
    424     @TestTargetNew(
    425         level = TestLevel.PARTIAL_COMPLETE,
    426         notes = "Verifies import of TEXT_NODE.",
    427         method = "importNode",
    428         args = {org.w3c.dom.Node.class, boolean.class}
    429     )
    430     public void testImportNode15() throws Throwable {
    431         Document doc;
    432 
    433         Node textImport;
    434         Node textToImport;
    435         String nodeValue;
    436         doc = (Document) load("staffNS", builder);
    437 
    438         textToImport = doc
    439                 .createTextNode("Document.importNode test for a TEXT_NODE");
    440         textImport = doc.importNode(textToImport, true);
    441         nodeValue = textImport.getNodeValue();
    442         assertEquals("documentimportnode15",
    443                 "Document.importNode test for a TEXT_NODE", nodeValue);
    444     }
    445     @TestTargetNew(
    446         level = TestLevel.PARTIAL_COMPLETE,
    447         notes = "Verifies import of COMMENT_NODE",
    448         method = "importNode",
    449         args = {org.w3c.dom.Node.class, boolean.class}
    450     )
    451     public void testImportNode17() throws Throwable {
    452         Document doc;
    453 
    454         Node commentImport;
    455         Node commentToImport;
    456         String nodeValue;
    457         doc = (Document) load("staffNS", builder);
    458 
    459         commentToImport = doc
    460                 .createComment("Document.importNode test for a COMMENT_NODE");
    461         commentImport = doc.importNode(commentToImport, true);
    462         nodeValue = commentImport.getNodeValue();
    463         assertEquals("documentimportnode17",
    464                 "Document.importNode test for a COMMENT_NODE", nodeValue);
    465     }
    466     @TestTargetNew(
    467         level = TestLevel.PARTIAL_COMPLETE,
    468         notes = "Doesn't verify DOMException exception.",
    469         method = "importNode",
    470         args = {org.w3c.dom.Node.class, boolean.class}
    471     )
    472     public void testImportNode18() throws Throwable {
    473         Document doc;
    474 
    475         ProcessingInstruction piImport;
    476         ProcessingInstruction piToImport;
    477         String piData;
    478         String piTarget;
    479         doc = (Document) load("staffNS", builder);
    480 
    481         piToImport = doc.createProcessingInstruction("Target", "Data");
    482         piImport = (ProcessingInstruction) doc.importNode(piToImport, false);
    483         piTarget = piImport.getTarget();
    484         piData = piImport.getData();
    485         assertEquals("documentimportnode18_Target", "Target", piTarget);
    486         assertEquals("documentimportnode18_Data", "Data", piData);
    487     }
    488 
    489 // Assumes validation.
    490 //    public void testImportNode19() throws Throwable {
    491 //        Document doc;
    492 //        DocumentType docTypeNull = null;
    493 //
    494 //        Document docImp;
    495 //        DOMImplementation domImpl;
    496 //        DocumentType docType;
    497 //        NamedNodeMap nodeMap;
    498 //        Entity entity2;
    499 //        Entity entity6;
    500 //        Entity entityImp2;
    501 //        Entity entityImp6;
    502 //        String nodeName;
    503 //        String systemId;
    504 //        String notationName;
    505 //        String nodeNameImp;
    506 //        String systemIdImp;
    507 //        String notationNameImp;
    508 //        doc = (Document) load("staffNS", builder);
    509 //        domImpl = doc.getImplementation();
    510 //        docType = doc.getDoctype();
    511 //        docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b",
    512 //                docTypeNull);
    513 //        nodeMap = docType.getEntities();
    514 //        assertNotNull("entitiesNotNull", nodeMap);
    515 //        entity2 = (Entity) nodeMap.getNamedItem("ent2");
    516 //        entity6 = (Entity) nodeMap.getNamedItem("ent6");
    517 //        entityImp2 = (Entity) docImp.importNode(entity2, false);
    518 //        entityImp6 = (Entity) docImp.importNode(entity6, true);
    519 //        nodeName = entity2.getNodeName();
    520 //        nodeNameImp = entityImp2.getNodeName();
    521 //        assertEquals("documentimportnode19_Ent2NodeName", nodeName, nodeNameImp);
    522 //        nodeName = entity6.getNodeName();
    523 //        nodeNameImp = entityImp6.getNodeName();
    524 //        assertEquals("documentimportnode19_Ent6NodeName", nodeName, nodeNameImp);
    525 //        systemId = entity2.getSystemId();
    526 //        systemIdImp = entityImp2.getSystemId();
    527 //        assertEquals("documentimportnode19_Ent2SystemId", systemId, systemIdImp);
    528 //        systemId = entity6.getSystemId();
    529 //        systemIdImp = entityImp6.getSystemId();
    530 //        assertEquals("documentimportnode19_Ent6SystemId", systemId, systemIdImp);
    531 //        notationName = entity2.getNotationName();
    532 //        notationNameImp = entityImp2.getNotationName();
    533 //        assertEquals("documentimportnode19_Ent2NotationName", notationName,
    534 //                notationNameImp);
    535 //        notationName = entity6.getNotationName();
    536 //        notationNameImp = entityImp6.getNotationName();
    537 //        assertEquals("documentimportnode19_Ent6NotationName", notationName,
    538 //                notationNameImp);
    539 //    }
    540 
    541 // Assumes validation.
    542 //    public void testImportNode20() throws Throwable {
    543 //        Document doc;
    544 //        Document docImp;
    545 //        DOMImplementation domImpl;
    546 //        DocumentType docType;
    547 //        DocumentType docTypeNull = null;
    548 //
    549 //        NamedNodeMap nodeMap;
    550 //        Entity entity4;
    551 //        Entity entityImp4;
    552 //        Element element;
    553 //        CharacterData cdata;
    554 //        ProcessingInstruction pi;
    555 //        NodeList childList;
    556 //        NodeList elemchildList;
    557 //        String ent4Name;
    558 //        String ent4ImpName;
    559 //        String cdataVal;
    560 //        String piTargetVal;
    561 //        String piDataVal;
    562 //        doc = (Document) load("staffNS", builder);
    563 //        domImpl = doc.getImplementation();
    564 //        docType = doc.getDoctype();
    565 //        docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b",
    566 //                docTypeNull);
    567 //        nodeMap = docType.getEntities();
    568 //        entity4 = (Entity) nodeMap.getNamedItem("ent4");
    569 //        entityImp4 = (Entity) docImp.importNode(entity4, true);
    570 //        childList = entityImp4.getChildNodes();
    571 //        element = (Element) childList.item(0);
    572 //        elemchildList = element.getChildNodes();
    573 //        cdata = (CharacterData) elemchildList.item(0);
    574 //        pi = (ProcessingInstruction) childList.item(1);
    575 //        ent4Name = entity4.getNodeName();
    576 //        ent4ImpName = entityImp4.getNodeName();
    577 //        cdataVal = cdata.getData();
    578 //        piTargetVal = pi.getTarget();
    579 //        piDataVal = pi.getData();
    580 //        assertEquals("documentimportnode20_Ent4NodeName", ent4Name, ent4ImpName);
    581 //        assertEquals("documentimportnode20_Cdata", "Element data", cdataVal);
    582 //        assertEquals("documentimportnode20_PITarget", "PItarget", piTargetVal);
    583 //        assertEquals("documentimportnode20_PIData", "PIdata", piDataVal);
    584 //    }
    585 
    586 // TODO Fails on JDK. Why?
    587 //    public void testImportNode21() throws Throwable {
    588 //
    589 //
    590 //        Document doc;
    591 //        DocumentType docTypeNull = null;
    592 //
    593 //        Document docImp;
    594 //        DOMImplementation domImpl;
    595 //        NodeList addressList;
    596 //        NodeList addressChildList;
    597 //        Element element;
    598 //        EntityReference entRef2;
    599 //        EntityReference entRefImp2;
    600 //        EntityReference entRef3;
    601 //        EntityReference entRefImp3;
    602 //        String nodeName2;
    603 //        String nodeName3;
    604 //        String nodeNameImp2;
    605 //        String nodeNameImp3;
    606 //        NodeList nodes;
    607 //        Node nodeImp3;
    608 //        Node nodeImp2;
    609 //        String nodeValueImp2;
    610 //        String nodeValueImp3;
    611 //        doc = (Document) load("staffNS", builder);
    612 //        domImpl = doc.getImplementation();
    613 //        docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b",
    614 //                docTypeNull);
    615 //        addressList = doc.getElementsByTagName("address");
    616 //        element = (Element) addressList.item(1);
    617 //        addressChildList = element.getChildNodes();
    618 //        entRef2 = (EntityReference) addressChildList.item(0);
    619 //        entRef3 = (EntityReference) addressChildList.item(2);
    620 //        entRefImp2 = (EntityReference) docImp.importNode(entRef2, true);
    621 //        entRefImp3 = (EntityReference) docImp.importNode(entRef3, false);
    622 //        nodeName2 = entRef2.getNodeName();
    623 //        nodeName3 = entRef3.getNodeName();
    624 //        nodeNameImp2 = entRefImp2.getNodeName();
    625 //        nodeNameImp3 = entRefImp3.getNodeName();
    626 //        assertEquals("documentimportnode21_Ent2NodeName", nodeName2,
    627 //                nodeNameImp2);
    628 //        assertEquals("documentimportnode21_Ent3NodeName", nodeName3,
    629 //                nodeNameImp3);
    630 //        entRefImp2 = (EntityReference) doc.importNode(entRef2, true);
    631 //        entRefImp3 = (EntityReference) doc.importNode(entRef3, false);
    632 //        nodes = entRefImp2.getChildNodes();
    633 //        nodeImp2 = nodes.item(0);
    634 //        nodeValueImp2 = nodeImp2.getNodeValue();
    635 //        nodes = entRefImp3.getChildNodes();
    636 //        nodeImp3 = nodes.item(0);
    637 //        nodeValueImp3 = nodeImp3.getNodeValue();
    638 //        assertEquals("documentimportnode21_Ent2NodeValue", "1900 Dallas Road",
    639 //                nodeValueImp2);
    640 //        assertEquals("documentimportnode21_Ent3Nodevalue", "Texas",
    641 //                nodeValueImp3);
    642 //
    643 //    }
    644 
    645 // Assumes validation.
    646 //    public void testImportNode22() throws Throwable {
    647 //        Document doc;
    648 //        DocumentType docTypeNull = null;
    649 //
    650 //        Document docImp;
    651 //        DOMImplementation domImpl;
    652 //        DocumentType docType;
    653 //        NamedNodeMap nodeMap;
    654 //        Notation notation1;
    655 //        Notation notation2;
    656 //
    657 //        String publicId1;
    658 //        String publicId1Imp;
    659 //        String publicId1NewImp;
    660 //        String publicId2Imp;
    661 //
    662 //        String systemId1Imp;
    663 //        String systemId1NewImp;
    664 //        String systemId2;
    665 //        String systemId2Imp;
    666 //        String systemId2NewImp;
    667 //        doc = (Document) load("staffNS", builder);
    668 //        domImpl = doc.getImplementation();
    669 //        docType = doc.getDoctype();
    670 //        docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b",
    671 //                docTypeNull);
    672 //        nodeMap = docType.getNotations();
    673 //        assertNotNull("notationsNotNull", nodeMap);
    674 //        notation1 = (Notation) nodeMap.getNamedItem("notation1");
    675 //        notation2 = (Notation) nodeMap.getNamedItem("notation2");
    676 //        doc.importNode(notation1, true);
    677 //        doc.importNode(notation2, false);
    678 //        docImp.importNode(notation1, false);
    679 //        docImp.importNode(notation2, true);
    680 //        publicId1 = notation1.getPublicId();
    681 //        publicId1Imp = notation1.getPublicId();
    682 //        publicId1NewImp = notation1.getPublicId();
    683 //        systemId1Imp = notation1.getSystemId();
    684 //        systemId1NewImp = notation1.getSystemId();
    685 //        publicId2Imp = notation2.getPublicId();
    686 //        notation2.getPublicId();
    687 //        systemId2 = notation2.getSystemId();
    688 //        systemId2Imp = notation2.getSystemId();
    689 //        systemId2NewImp = notation2.getSystemId();
    690 //        assertEquals("documentimportnode22_N1PID", publicId1, publicId1Imp);
    691 //        assertEquals("documentimportnode22_N1NPID", publicId1, publicId1NewImp);
    692 //        assertNull("documentimportnode22_N1SID", systemId1Imp);
    693 //        assertNull("documentimportnode22_N1NSID", systemId1NewImp);
    694 //        assertEquals("documentimportnode22_N2SID", systemId2, systemId2Imp);
    695 //        assertEquals("documentimportnode22_N2NSID", systemId2, systemId2NewImp);
    696 //        assertNull("documentimportnode22_N2PID", publicId2Imp);
    697 //        assertNull("documentimportnode22_N2NPID", publicId2Imp);
    698 //    }
    699 }
    700