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-2004 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 * Attempt to append a text node from another document to an attribute which should result 32 * in a WRONG_DOCUMENT_ERR. 33 * @author Curt Arnold 34 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024</a> 35 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727</a> 36 */ 37 public final class hc_attrinsertbefore6 extends DOMTestCase { 38 39 /** 40 * Constructor. 41 * @param factory document factory, may not be null 42 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 43 */ 44 public hc_attrinsertbefore6(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 45 super(factory); 46 47 // 48 // check if loaded documents are supported for content type 49 // 50 String contentType = getContentType(); 51 preload(contentType, "hc_staff", true); 52 preload(contentType, "hc_staff", true); 53 } 54 55 /** 56 * Runs the test case. 57 * @throws Throwable Any uncaught exception causes test to fail 58 */ 59 public void runTest() throws Throwable { 60 Document doc; 61 NodeList acronymList; 62 Node testNode; 63 NamedNodeMap attributes; 64 Attr titleAttr; 65 String value; 66 Node textNode; 67 Node retval; 68 Node refChild = null; 69 70 Document otherDoc; 71 doc = (Document) load("hc_staff", true); 72 otherDoc = (Document) load("hc_staff", true); 73 acronymList = doc.getElementsByTagName("acronym"); 74 testNode = acronymList.item(3); 75 attributes = testNode.getAttributes(); 76 titleAttr = (Attr) attributes.getNamedItem("title"); 77 textNode = otherDoc.createTextNode("terday"); 78 79 { 80 boolean success = false; 81 try { 82 retval = titleAttr.insertBefore(textNode, refChild); 83 } catch (DOMException ex) { 84 success = (ex.code == DOMException.WRONG_DOCUMENT_ERR); 85 } 86 assertTrue("throw_WRONG_DOCUMENT_ERR", success); 87 } 88 } 89 /** 90 * Gets URI that identifies the test. 91 * @return uri identifier of test 92 */ 93 public String getTargetURI() { 94 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrinsertbefore6"; 95 } 96 /** 97 * Runs this test from the command line. 98 * @param args command line arguments 99 */ 100 public static void main(final String[] args) { 101 DOMTestCase.doMain(hc_attrinsertbefore6.class, args); 102 } 103 } 104 105