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 *   Create a new DocumentFragment and add a newly created Element node(with one attribute).
32 *   Once the element is added, its attribute should be available as an attribute associated
33 *   with an Element within a DocumentFragment.
34* @author Curt Arnold
35* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5</a>
36* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082</a>
37* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3</a>
38* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=236">http://www.w3.org/Bugs/Public/show_bug.cgi?id=236</a>
39* @see <a href="http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html">http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html</a>
40* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=184">http://www.w3.org/Bugs/Public/show_bug.cgi?id=184</a>
41*/
42public final class hc_attrcreatedocumentfragment extends DOMTestCase {
43
44   /**
45    * Constructor.
46    * @param factory document factory, may not be null
47    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
48    */
49   public hc_attrcreatedocumentfragment(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
50      super(factory);
51
52    //
53    //   check if loaded documents are supported for content type
54    //
55    String contentType = getContentType();
56    preload(contentType, "hc_staff", true);
57    }
58
59   /**
60    * Runs the test case.
61    * @throws Throwable Any uncaught exception causes test to fail
62    */
63   public void runTest() throws Throwable {
64      Document doc;
65      DocumentFragment docFragment;
66      Element newOne;
67      Node domesticNode;
68      NamedNodeMap attributes;
69      Attr attribute;
70      String attrName;
71      Node appendedChild;
72      int langAttrCount = 0;
73      doc = (Document) load("hc_staff", true);
74      docFragment = doc.createDocumentFragment();
75      newOne = doc.createElement("html");
76      newOne.setAttribute("lang", "EN");
77      appendedChild = docFragment.appendChild(newOne);
78      domesticNode = docFragment.getFirstChild();
79      attributes = domesticNode.getAttributes();
80      for (int indexN10078 = 0; indexN10078 < attributes.getLength(); indexN10078++) {
81          attribute = (Attr) attributes.item(indexN10078);
82    attrName = attribute.getNodeName();
83
84      if (equalsAutoCase("attribute", "lang", attrName)) {
85          langAttrCount += 1;
86      }
87      }
88      assertEquals("hasLangAttr", 1, langAttrCount);
89      }
90   /**
91    *  Gets URI that identifies the test.
92    *  @return uri identifier of test
93    */
94   public String getTargetURI() {
95      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_attrcreatedocumentfragment";
96   }
97   /**
98    * Runs this test from the command line.
99    * @param args command line arguments
100    */
101   public static void main(final String[] args) {
102        DOMTestCase.doMain(hc_attrcreatedocumentfragment.class, args);
103   }
104}
105
106