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 "setNamedItemNS(arg)" method for a 35 * NamedNodeMap should raise INUSE_ATTRIBUTE_ERR DOMException if 36 * arg is an Attr that is already an attribute of another Element object. 37 * 38 * Retrieve an attr node from the third "address" element whose local name 39 * is "domestic" and namespaceURI is "http://www.netzero.com". 40 * Invoke method setNamedItemNS(arg) on the map of the first "address" element with 41 * arg being the attr node from above. Method should raise 42 * INUSE_ATTRIBUTE_ERR DOMException. 43* @author NIST 44* @author Mary Brady 45* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])</a> 46* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS</a> 47* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])">http://www.w3.org/TR/DOM-Level-2-Core/core#xpointer(id('ID-setNamedItemNS')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])</a> 48*/ 49public final class setNamedItemNS01 extends DOMTestCase { 50 51 /** 52 * Constructor. 53 * @param factory document factory, may not be null 54 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 55 */ 56 public setNamedItemNS01(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 57 58 org.w3c.domts.DocumentBuilderSetting[] settings = 59 new org.w3c.domts.DocumentBuilderSetting[] { 60org.w3c.domts.DocumentBuilderSetting.namespaceAware 61 }; 62 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings); 63 setFactory(testFactory); 64 65 // 66 // check if loaded documents are supported for content type 67 // 68 String contentType = getContentType(); 69 preload(contentType, "staffNS", 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 NodeList elementList; 79 Node anotherElement; 80 NamedNodeMap anotherMap; 81 Node arg; 82 Node testAddress; 83 NamedNodeMap map; 84 Node setNode; 85 doc = (Document) load("staffNS", true); 86 elementList = doc.getElementsByTagName("address"); 87 anotherElement = elementList.item(2); 88 anotherMap = anotherElement.getAttributes(); 89 arg = anotherMap.getNamedItemNS("http://www.netzero.com", "domestic"); 90 testAddress = elementList.item(0); 91 map = testAddress.getAttributes(); 92 93 { 94 boolean success = false; 95 try { 96 setNode = map.setNamedItemNS(arg); 97 } catch (DOMException ex) { 98 success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); 99 } 100 assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); 101 } 102} 103 /** 104 * Gets URI that identifies the test. 105 * @return uri identifier of test 106 */ 107 public String getTargetURI() { 108 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/setNamedItemNS01"; 109 } 110 /** 111 * Runs this test from the command line. 112 * @param args command line arguments 113 */ 114 public static void main(final String[] args) { 115 DOMTestCase.doMain(setNamedItemNS01.class, args); 116 } 117} 118 119