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 
      9 Copyright (c) 2001 World Wide Web Consortium,
     10 (Massachusetts Institute of Technology, Institut National de
     11 Recherche en Informatique et en Automatique, Keio University).  All
     12 Rights Reserved.  This program is distributed under the W3C's Software
     13 Intellectual Property License.  This program is distributed in the
     14 hope that it will be useful, but WITHOUT ANY WARRANTY; without even
     15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     16 PURPOSE.
     17 
     18 See W3C License http://www.w3.org/Consortium/Legal/ for more details.
     19 
     20 
     21 */
     22 
     23 package org.w3c.domts.level2.core;
     24 
     25 import org.w3c.dom.*;
     26 
     27 
     28 import org.w3c.domts.DOMTestCase;
     29 import org.w3c.domts.DOMTestDocumentBuilderFactory;
     30 
     31 
     32 
     33 /**
     34  *     The "hasAttributeNS()" method for an Element should
     35  *    return false if the element does not have an attribute with the given local name
     36  *    and/or namespace URI specified on this element or does not have a default value.
     37  *    Retrieve the first "address" element and the "hasAttributeNS()" method
     38  *    should return false since the element has "domestic" as the local name
     39  *    and "http://www.nomatch.com" as the namespace URI.
     40 * @author NIST
     41 * @author Mary Brady
     42 * @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>
     43 */
     44 public final class hasAttributeNS02 extends DOMTestCase {
     45 
     46    /**
     47     * Constructor.
     48     * @param factory document factory, may not be null
     49     * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
     50     */
     51    public hasAttributeNS02(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
     52       super(factory);
     53 
     54     //
     55     //   check if loaded documents are supported for content type
     56     //
     57     String contentType = getContentType();
     58     preload(contentType, "staffNS", false);
     59     }
     60 
     61    /**
     62     * Runs the test case.
     63     * @throws Throwable Any uncaught exception causes test to fail
     64     */
     65    public void runTest() throws Throwable {
     66       String localName = "domestic";
     67       String namespaceURI = "http://www.nomatch.com";
     68       Document doc;
     69       NodeList elementList;
     70       Element testNode;
     71       boolean state;
     72       doc = (Document) load("staffNS", false);
     73       elementList = doc.getElementsByTagName("address");
     74       testNode = (Element) elementList.item(0);
     75       state = testNode.hasAttributeNS(namespaceURI, localName);
     76       assertFalse("throw_False", state);
     77 }
     78    /**
     79     *  Gets URI that identifies the test.
     80     *  @return uri identifier of test
     81     */
     82    public String getTargetURI() {
     83       return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/hasAttributeNS02";
     84    }
     85    /**
     86     * Runs this test from the command line.
     87     * @param args command line arguments
     88     */
     89    public static void main(final String[] args) {
     90         DOMTestCase.doMain(hasAttributeNS02.class, args);
     91    }
     92 }
     93 
     94