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
8
9Copyright (c) 2001-2003 World Wide Web Consortium,
10(Massachusetts Institute of Technology, Institut National de
11Recherche en Informatique et en Automatique, Keio University).  All
12Rights Reserved.  This program is distributed under the W3C's Software
13Intellectual Property License.  This program is distributed in the
14hope that it will be useful, but WITHOUT ANY WARRANTY; without even
15the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16PURPOSE.
17
18See W3C License http://www.w3.org/Consortium/Legal/ for more details.
19
20
21*/
22
23package org.w3c.domts.level2.core;
24
25import org.w3c.dom.*;
26
27
28import org.w3c.domts.DOMTestCase;
29import org.w3c.domts.DOMTestDocumentBuilderFactory;
30
31
32
33/**
34 *       The method hasAttributeNS returns true when an attribute with a given local name
35 *       and namespace URI is specified on this element or has a default value,
36 *       false otherwise.
37 *
38 *       Create a new element and an attribute node that has an empty namespace.
39 *       Add the attribute node to the element node.  Check if the newly created element
40 *       node has an attribute by invoking the hasAttributeNS method with appropriate
41 *       values for the namespaceURI and localName parameters.
42 *
43* @author IBM
44* @author Neil Delima
45* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-ElHasAttrNS</a>
46* @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=259">http://www.w3.org/Bugs/Public/show_bug.cgi?id=259</a>
47*/
48public final class elementhasattributens03 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 elementhasattributens03(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
56
57      org.w3c.domts.DocumentBuilderSetting[] settings =
58          new org.w3c.domts.DocumentBuilderSetting[] {
59org.w3c.domts.DocumentBuilderSetting.namespaceAware
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", false);
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      Element element;
78      boolean state;
79      Attr attribute;
80      Attr newAttribute;
81      String nullNS = null;
82
83      doc = (Document) load("staff", false);
84      element = doc.createElementNS("http://www.w3.org/DOM", "address");
85      assertNotNull("createElementNotNull", element);
86      attribute = doc.createAttributeNS(nullNS, "domestic");
87      newAttribute = element.setAttributeNode(attribute);
88      state = element.hasAttributeNS(nullNS, "domestic");
89      assertTrue("elementhasattributens03", state);
90      }
91   /**
92    *  Gets URI that identifies the test.
93    *  @return uri identifier of test
94    */
95   public String getTargetURI() {
96      return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/elementhasattributens03";
97   }
98   /**
99    * Runs this test from the command line.
100    * @param args command line arguments
101    */
102   public static void main(final String[] args) {
103        DOMTestCase.doMain(elementhasattributens03.class, args);
104   }
105}
106
107