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 * Sets Attr.value on an attribute that only has a simple value.
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*/
35public final class hc_attrsetvalue1 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_attrsetvalue1(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      Node retval;
64      Node firstChild;
65      Node otherChild;
66      doc = (Document) load("hc_staff", true);
67      acronymList = doc.getElementsByTagName("acronym");
68      testNode = acronymList.item(3);
69      attributes = testNode.getAttributes();
70      titleAttr = (Attr) attributes.getNamedItem("title");
71      firstChild = titleAttr.getFirstChild();
72      assertNotNull("attrChildNotNull", firstChild);
73      titleAttr.setValue("Tomorrow");
74      firstChild.setNodeValue("impl reused node");
75      value = titleAttr.getValue();
76      assertEquals("attrValue", "Tomorrow", value);
77      value = titleAttr.getNodeValue();
78      assertEquals("attrNodeValue", "Tomorrow", value);
79      firstChild = titleAttr.getLastChild();
80      value = firstChild.getNodeValue();
81      assertEquals("firstChildValue", "Tomorrow", value);
82      otherChild = firstChild.getNextSibling();
83      assertNull("nextSiblingIsNull", otherChild);
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/hc_attrsetvalue1";
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(hc_attrsetvalue1.class, args);
98   }
99}
100
101