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-2004 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 "removeAttributeNode(oldAttr)" method removes the
32 *    specified attribute node and restores any default values.
33 *
34 *    Retrieve the last child of the third employeed and
35 *    remove its "street" Attr node.  Since this node has a
36 *    default value defined in the DTD file, that default
37 *    should immediately be the new value.
38* @author NIST
39* @author Mary Brady
40* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198</a>
41* @see <a href="http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html">http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html</a>
42*/
43public final class elementremoveattributerestoredefaultvalue extends DOMTestCase {
44
45   /**
46    * Constructor.
47    * @param factory document factory, may not be null
48    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
49    */
50   public elementremoveattributerestoredefaultvalue(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
51
52      org.w3c.domts.DocumentBuilderSetting[] settings =
53          new org.w3c.domts.DocumentBuilderSetting[] {
54org.w3c.domts.DocumentBuilderSetting.validating
55        };
56        DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
57        setFactory(testFactory);
58
59    //
60    //   check if loaded documents are supported for content type
61    //
62    String contentType = getContentType();
63    preload(contentType, "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 doc;
72      NodeList elementList;
73      Element testEmployee;
74      Attr streetAttr;
75      String attribute;
76      Attr removedAttr;
77      doc = (Document) load("staff", true);
78      elementList = doc.getElementsByTagName("address");
79      testEmployee = (Element) elementList.item(2);
80      streetAttr = testEmployee.getAttributeNode("street");
81      removedAttr = testEmployee.removeAttributeNode(streetAttr);
82      attribute = testEmployee.getAttribute("street");
83      assertEquals("streetYes", "Yes", attribute);
84      }
85   /**
86    *  Gets URI that identifies the test.
87    *  @return uri identifier of test
88    */
89   public String getTargetURI() {
90      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributerestoredefaultvalue";
91   }
92   /**
93    * Runs this test from the command line.
94    * @param args command line arguments
95    */
96   public static void main(final String[] args) {
97        DOMTestCase.doMain(elementremoveattributerestoredefaultvalue.class, args);
98   }
99}
100
101