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  * Sets Attr.value on an attribute that should contain multiple child nodes.
     32 * @author Curt Arnold
     33 * @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>
     34 */
     35 public final class hc_attrsetvalue2 extends DOMTestCase {
     36 
     37    /**
     38     * Constructor.
     39     * @param factory document factory, may not be null
     40     * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
     41     */
     42    public hc_attrsetvalue2(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
     43       super(factory);
     44 
     45     //
     46     //   check if loaded documents are supported for content type
     47     //
     48     String contentType = getContentType();
     49     preload(contentType, "hc_staff", true);
     50     }
     51 
     52    /**
     53     * Runs the test case.
     54     * @throws Throwable Any uncaught exception causes test to fail
     55     */
     56    public void runTest() throws Throwable {
     57       Document doc;
     58       NodeList acronymList;
     59       Node testNode;
     60       NamedNodeMap attributes;
     61       Attr titleAttr;
     62       String value;
     63       Text textNode;
     64       Node retval;
     65       Node firstChild;
     66       Node otherChild;
     67       doc = (Document) load("hc_staff", true);
     68       acronymList = doc.getElementsByTagName("acronym");
     69       testNode = acronymList.item(3);
     70       attributes = testNode.getAttributes();
     71       titleAttr = (Attr) attributes.getNamedItem("title");
     72       textNode = doc.createTextNode("terday");
     73       retval = titleAttr.appendChild(textNode);
     74       firstChild = titleAttr.getFirstChild();
     75       assertNotNull("attrChildNotNull", firstChild);
     76       titleAttr.setValue("Tomorrow");
     77       firstChild.setNodeValue("impl reused node");
     78       value = titleAttr.getValue();
     79       assertEquals("attrValue", "Tomorrow", value);
     80       value = titleAttr.getNodeValue();
     81       assertEquals("attrNodeValue", "Tomorrow", value);
     82       firstChild = titleAttr.getLastChild();
     83       value = firstChild.getNodeValue();
     84       assertEquals("firstChildValue", "Tomorrow", value);
     85       otherChild = firstChild.getNextSibling();
     86       assertNull("nextSiblingIsNull", otherChild);
     87       }
     88    /**
     89     *  Gets URI that identifies the test.
     90     *  @return uri identifier of test
     91     */
     92    public String getTargetURI() {
     93       return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrsetvalue2";
     94    }
     95    /**
     96     * Runs this test from the command line.
     97     * @param args command line arguments
     98     */
     99    public static void main(final String[] args) {
    100         DOMTestCase.doMain(hc_attrsetvalue2.class, args);
    101    }
    102 }
    103 
    104