Home | History | Annotate | Download | only in core
      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  *     If the node removed by the "removeNamedItem(name)" method
     32  *    is an Attr node with a default value it is immediately
     33  *    replaced.
     34  *
     35  *    Retrieve the third employee and create a NamedNodeMap
     36  *    object of the attributes of the last child.  Once the
     37  *    list is created invoke the "removeNamedItem(name)"
     38  *    method with name="street".  The "removeNamedItem(name)"
     39  *    method should remove the "street" attribute and since
     40  *    it has a default value of "Yes", that value should
     41  *    immediately be the attributes value.
     42 * @author NIST
     43 * @author Mary Brady
     44 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193</a>
     45 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9</a>
     46 * @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>
     47 */
     48 public final class namednodemapremovenameditemgetvalue extends DOMTestCase {
     49 
     50    /**
     51     * Constructor.
     52     * @param factory document factory, may not be null
     53     * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
     54     */
     55    public namednodemapremovenameditemgetvalue(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
     56 
     57       org.w3c.domts.DocumentBuilderSetting[] settings =
     58           new org.w3c.domts.DocumentBuilderSetting[] {
     59 org.w3c.domts.DocumentBuilderSetting.validating
     60         };
     61         DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
     62         setFactory(testFactory);
     63 
     64     //
     65     //   check if loaded documents are supported for content type
     66     //
     67     String contentType = getContentType();
     68     preload(contentType, "staff", true);
     69     }
     70 
     71    /**
     72     * Runs the test case.
     73     * @throws Throwable Any uncaught exception causes test to fail
     74     */
     75    public void runTest() throws Throwable {
     76       Document doc;
     77       NodeList elementList;
     78       Node testEmployee;
     79       NamedNodeMap attributes;
     80       Attr streetAttr;
     81       String value;
     82       Node removedNode;
     83       doc = (Document) load("staff", true);
     84       elementList = doc.getElementsByTagName("address");
     85       testEmployee = elementList.item(2);
     86       attributes = testEmployee.getAttributes();
     87       assertNotNull("attributesNotNull", attributes);
     88       removedNode = attributes.removeNamedItem("street");
     89       streetAttr = (Attr) attributes.getNamedItem("street");
     90       assertNotNull("streetAttrNotNull", streetAttr);
     91       value = streetAttr.getValue();
     92       assertEquals("namednodemapRemoveNamedItemGetValueAssert", "Yes", value);
     93       }
     94    /**
     95     *  Gets URI that identifies the test.
     96     *  @return uri identifier of test
     97     */
     98    public String getTargetURI() {
     99       return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/namednodemapremovenameditemgetvalue";
    100    }
    101    /**
    102     * Runs this test from the command line.
    103     * @param args command line arguments
    104     */
    105    public static void main(final String[] args) {
    106         DOMTestCase.doMain(namednodemapremovenameditemgetvalue.class, args);
    107    }
    108 }
    109 
    110