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 Copyright (c) 2001-2003 World Wide Web Consortium, 9 (Massachusetts Institute of Technology, Institut National de 10 Recherche en Informatique et en Automatique, Keio University). All 11 Rights Reserved. This program is distributed under the W3C's Software 12 Intellectual Property License. This program is distributed in the 13 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 PURPOSE. 16 See W3C License http://www.w3.org/Consortium/Legal/ for more details. 17 18 */ 19 20 package org.w3c.domts.level1.core; 21 22 import org.w3c.dom.*; 23 24 25 import org.w3c.domts.DOMTestCase; 26 import org.w3c.domts.DOMTestDocumentBuilderFactory; 27 28 29 30 /** 31 * The "setNamedItem(arg)" method raises a 32 * WRONG_DOCUMENT_ERR DOMException if "arg" was created 33 * from a different document than the one that created 34 * the NamedNodeMap. 35 * 36 * Create a NamedNodeMap object from the attributes of the 37 * last child of the third employee and attempt to add 38 * another Attr node to it that was created from a 39 * different DOM document. This should raise the desired 40 * exception. This method uses the "createAttribute(name)" 41 * method from the Document interface. 42 * @author Curt Arnold 43 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])</a> 44 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788</a> 45 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1025163788')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1025163788')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])</a> 46 * @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=249">http://www.w3.org/Bugs/Public/show_bug.cgi?id=249</a> 47 */ 48 public final class hc_namednodemapwrongdocumenterr 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 hc_namednodemapwrongdocumenterr(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, "hc_staff", true); 63 preload(contentType, "hc_staff", 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 doc1; 72 Document doc2; 73 NodeList elementList; 74 Node testAddress; 75 NamedNodeMap attributes; 76 Node newAttribute; 77 String strong; 78 Node setNode; 79 doc1 = (Document) load("hc_staff", true); 80 doc2 = (Document) load("hc_staff", true); 81 elementList = doc1.getElementsByTagName("acronym"); 82 testAddress = elementList.item(2); 83 newAttribute = doc2.createAttribute("newAttribute"); 84 attributes = testAddress.getAttributes(); 85 86 { 87 boolean success = false; 88 try { 89 setNode = attributes.setNamedItem(newAttribute); 90 } catch (DOMException ex) { 91 success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); 92 } 93 assertTrue("throw_WRONG_DOCUMENT_ERR", success); 94 } 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/level1/core/hc_namednodemapwrongdocumenterr"; 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(hc_namednodemapwrongdocumenterr.class, args); 109 } 110 } 111 112