1 2/* 3This Java source file was generated by test-to-java.xsl 4and is a derived work from the source document. 5The source document contained the following notice: 6 7 8 9Copyright (c) 2001-2003 World Wide Web Consortium, 10(Massachusetts Institute of Technology, Institut National de 11Recherche en Informatique et en Automatique, Keio University). All 12Rights Reserved. This program is distributed under the W3C's Software 13Intellectual Property License. This program is distributed in the 14hope that it will be useful, but WITHOUT ANY WARRANTY; without even 15the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 16PURPOSE. 17 18See W3C License http://www.w3.org/Consortium/Legal/ for more details. 19 20 21*/ 22 23package org.w3c.domts.level2.core; 24 25import org.w3c.dom.*; 26 27 28import org.w3c.domts.DOMTestCase; 29import org.w3c.domts.DOMTestDocumentBuilderFactory; 30 31 32 33/** 34 * Using the method importNode with deep=true, import the fourth employee element node of this 35 * Document. Verify if the node has been imported correctly by checking 36 * if the default attribute present on this node has not been imported 37 * and an explicit attribute has been imported. 38* @author IBM 39* @author Neil Delima 40* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core">http://www.w3.org/TR/DOM-Level-2-Core/core</a> 41* @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> 42* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=259">http://www.w3.org/Bugs/Public/show_bug.cgi?id=259</a> 43* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=402">http://www.w3.org/Bugs/Public/show_bug.cgi?id=402</a> 44*/ 45public final class documentimportnode14 extends DOMTestCase { 46 47 /** 48 * Constructor. 49 * @param factory document factory, may not be null 50 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 51 */ 52 public documentimportnode14(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 53 54 org.w3c.domts.DocumentBuilderSetting[] settings = 55 new org.w3c.domts.DocumentBuilderSetting[] { 56org.w3c.domts.DocumentBuilderSetting.namespaceAware 57 }; 58 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); 59 setFactory(testFactory); 60 61 // 62 // check if loaded documents are supported for content type 63 // 64 String contentType = getContentType(); 65 preload(contentType, "staffNS", true); 66 } 67 68 /** 69 * Runs the test case. 70 * @throws Throwable Any uncaught exception causes test to fail 71 */ 72 public void runTest() throws Throwable { 73 Document doc; 74 Document newDoc; 75 DOMImplementation domImpl; 76 DocumentType nullDocType = null; 77 78 NodeList childList; 79 Node imported; 80 Node employeeElem; 81 Attr attrNode; 82 String attrValue; 83 String nullNS = null; 84 85 doc = (Document) load("staffNS", true); 86 childList = doc.getElementsByTagNameNS("*", "employee"); 87 employeeElem = childList.item(3); 88 domImpl = getImplementation(); 89 newDoc = domImpl.createDocument(nullNS, "staff", nullDocType); 90 imported = newDoc.importNode(employeeElem, true); 91 attrNode = ((Element) /*Node */imported).getAttributeNodeNS(nullNS, "defaultAttr"); 92 assertNull("defaultAttrNotImported", attrNode); 93 attrValue = ((Element) /*Node */imported).getAttributeNS("http://www.w3.org/2000/xmlns/", "emp"); 94 assertEquals("explicitAttrImported", "http://www.nist.gov", attrValue); 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/documentimportnode14"; 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(documentimportnode14.class, args); 109 } 110} 111 112