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 8Copyright (c) 2001 World Wide Web Consortium, 9(Massachusetts Institute of Technology, Institut National de 10Recherche en Informatique et en Automatique, Keio University). All 11Rights Reserved. This program is distributed under the W3C's Software 12Intellectual Property License. This program is distributed in the 13hope that it will be useful, but WITHOUT ANY WARRANTY; without even 14the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15PURPOSE. 16See W3C License http://www.w3.org/Consortium/Legal/ for more details. 17 18*/ 19 20package org.w3c.domts.level1.core; 21 22import org.w3c.dom.*; 23 24 25import org.w3c.domts.DOMTestCase; 26import org.w3c.domts.DOMTestDocumentBuilderFactory; 27 28 29 30/** 31 * The "setValue()" method for an attribute causes the 32 * DOMException NO_MODIFICATION_ALLOWED_ERR to be raised 33 * if the node is readonly. 34 * Create an entity reference using document.createEntityReference() 35 * Get the "domestic" attribute from the entity 36 * reference and execute the "setValue()" method. 37 * This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown. 38* @author Curt Arnold 39* @see <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])">http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])</a> 40* @see <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#ID-221662474">http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#ID-221662474</a> 41* @see <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-221662474')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])">http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-221662474')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])</a> 42* @see <a href="http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html">http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html</a> 43* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474</a> 44* @see <a href="http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrsetvaluenomodificationallowederr.xml">http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrsetvaluenomodificationallowederr.xml</a> 45*/ 46public final class attrsetvaluenomodificationallowederrEE extends DOMTestCase { 47 48 /** 49 * Constructor. 50 * @param factory document factory, may not be null 51 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 52 */ 53 public attrsetvaluenomodificationallowederrEE(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 54 super(factory); 55 56 // 57 // check if loaded documents are supported for content type 58 // 59 String contentType = getContentType(); 60 preload(contentType, "staff", true); 61 } 62 63 /** 64 * Runs the test case. 65 * @throws Throwable Any uncaught exception causes test to fail 66 */ 67 public void runTest() throws Throwable { 68 Document doc; 69 EntityReference entRef; 70 Element entElement; 71 NamedNodeMap attrList; 72 Node attrNode; 73 Node gender; 74 NodeList genderList; 75 Node appendedChild; 76 doc = (Document) load("staff", true); 77 genderList = doc.getElementsByTagName("gender"); 78 gender = genderList.item(2); 79 assertNotNull("genderNotNull", gender); 80 entRef = doc.createEntityReference("ent4"); 81 assertNotNull("entRefNotNull", entRef); 82 appendedChild = gender.appendChild(entRef); 83 entElement = (Element) entRef.getFirstChild(); 84 assertNotNull("entElementNotNull", entElement); 85 attrList = entElement.getAttributes(); 86 attrNode = attrList.getNamedItem("domestic"); 87 88 { 89 boolean success = false; 90 try { 91 ((Attr) /*Node */attrNode).setValue("newvalue"); 92 } catch (DOMException ex) { 93 success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); 94 } 95 assertTrue("setValue_throws_NO_MODIFICATION", success); 96 } 97 98 { 99 boolean success = false; 100 try { 101 attrNode.setNodeValue("newvalue2"); 102 } catch (DOMException ex) { 103 success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); 104 } 105 assertTrue("setNodeValue_throws_NO_MODIFICATION", success); 106 } 107} 108 /** 109 * Gets URI that identifies the test. 110 * @return uri identifier of test 111 */ 112 public String getTargetURI() { 113 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrsetvaluenomodificationallowederrEE"; 114 } 115 /** 116 * Runs this test from the command line. 117 * @param args command line arguments 118 */ 119 public static void main(final String[] args) { 120 DOMTestCase.doMain(attrsetvaluenomodificationallowederrEE.class, args); 121 } 122} 123 124