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 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 * The importNode method imports a node from another document to this document. 35 * The returned node has no parent; (parentNode is null). The source node is not 36 * altered or removed from the original document but a new copy of the source node 37 * is created. 38 * 39 * Using the method importNode with deep=false, import a newly created attribute node, 40 * into the another document. 41 * Check the nodeName, nodeType and nodeValue namespaceURI of the imported node to 42 * verify if it has been imported correctly. 43* @author IBM 44* @author Neil Delima 45* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core">http://www.w3.org/TR/DOM-Level-2-Core/core</a> 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*/ 48public final class documentimportnode05 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 documentimportnode05(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 56 57 org.w3c.domts.DocumentBuilderSetting[] settings = 58 new org.w3c.domts.DocumentBuilderSetting[] { 59org.w3c.domts.DocumentBuilderSetting.namespaceAware 60 }; 61 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); 62 setFactory(testFactory); 63 64 // 65 // check if loaded documents are supported for content type 66 // 67 String contentType = getContentType(); 68 preload(contentType, "staffNS", true); 69 preload(contentType, "staff", true); 70 } 71 72 /** 73 * Runs the test case. 74 * @throws Throwable Any uncaught exception causes test to fail 75 */ 76 public void runTest() throws Throwable { 77 Document doc; 78 Document docImported; 79 Attr attr; 80 Node importedAttr; 81 String nodeName; 82 int nodeType; 83 String nodeValue; 84 String namespaceURI; 85 doc = (Document) load("staffNS", true); 86 docImported = (Document) load("staff", true); 87 attr = doc.createAttributeNS("http://www.w3.org/DOM/Test", "a_:b0"); 88 importedAttr = docImported.importNode(attr, false); 89 nodeName = importedAttr.getNodeName(); 90 nodeValue = importedAttr.getNodeValue(); 91 nodeType = (int) importedAttr.getNodeType(); 92 namespaceURI = importedAttr.getNamespaceURI(); 93 assertEquals("documentimportnode05_nodeName", "a_:b0", nodeName); 94 assertEquals("documentimportnode05_nodeType", 2, nodeType); 95 assertEquals("documentimportnode05_nodeValue", "", nodeValue); 96 assertEquals("documentimportnode05_namespaceURI", "http://www.w3.org/DOM/Test", namespaceURI); 97 } 98 /** 99 * Gets URI that identifies the test. 100 * @return uri identifier of test 101 */ 102 public String getTargetURI() { 103 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode05"; 104 } 105 /** 106 * Runs this test from the command line. 107 * @param args command line arguments 108 */ 109 public static void main(final String[] args) { 110 DOMTestCase.doMain(documentimportnode05.class, args); 111 } 112} 113 114