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:
9 Copyright (c) 2001-2003 World Wide Web Consortium,
10 (Massachusetts Institute of Technology, Institut National de
11 Recherche en Informatique et en Automatique, Keio University). All
12 Rights Reserved. This program is distributed under the W3C's Software
13 Intellectual Property License. This program is distributed in the
14 hope that it will be useful, but WITHOUT ANY WARRANTY; without even
15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 See W3C License http://www.w3.org/Consortium/Legal/ for more details.
23 package org.w3c.domts.level2.core;
28 import org.w3c.domts.DOMTestCase;
29 import org.w3c.domts.DOMTestDocumentBuilderFactory;
34 * The method setAttributeNodeNS adds a new attribute and raises the
35 * INUSE_ATTRIBUTE_ERR exception if the newAttr is already an attribute of
36 * another Element object.
38 * Retreive an attribute node of an existing element node. Attempt to add it to an another
39 * element node. Check if the INUSE_ATTRIBUTE_ERR exception is thrown.
43 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElSetAtNodeNS</a>
45 public final class elementsetattributenodens03 extends DOMTestCase {
49 * @param factory document factory, may not be null
50 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
52 public elementsetattributenodens03(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException {
54 org.w3c.domts.DocumentBuilderSetting[] settings =
55 new org.w3c.domts.DocumentBuilderSetting[] {
56 org.w3c.domts.DocumentBuilderSetting.namespaceAware,
57 org.w3c.domts.DocumentBuilderSetting.namespaceAware
59 DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
60 setFactory(testFactory);
63 // check if loaded documents are supported for content type
65 String contentType = getContentType();
66 preload(contentType, "staffNS", true);
71 * @throws Throwable Any uncaught exception causes test to fail
73 public void runTest() throws Throwable {
82 doc = (Document) load("staffNS", true);
83 elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address");
84 element1 = (Element) elementList.item(1);
85 attribute = element1.getAttributeNodeNS(nullNS, "street");
86 element2 = (Element) elementList.item(2);
89 boolean success = false;
91 newAttribute = element2.setAttributeNodeNS(attribute);
92 } catch (DOMException ex) {
93 success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR);
95 assertTrue("elementsetattributenodens03", success);
99 * Gets URI that identifies the test.
100 * @return uri identifier of test
102 public String getTargetURI() {
103 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementsetattributenodens03";
106 * Runs this test from the command line.
107 * @param args command line arguments
109 public static void main(final String[] args) {
110 DOMTestCase.doMain(elementsetattributenodens03.class, args);