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 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 removeNamedItemNS removes a node specified by local name and namespace
35 *
36 *  Attempt to remove the xmlns and dmstc attributes of the first element node with the localName
37 *  employee.  Verify if the 2 attributes were successfully removed.
38* @author IBM
39* @author Neil Delima
40* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D58B193</a>
41*/
42public final class namednodemapremovenameditemns04 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 namednodemapremovenameditemns04(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
50
51      org.w3c.domts.DocumentBuilderSetting[] settings =
52          new org.w3c.domts.DocumentBuilderSetting[] {
53org.w3c.domts.DocumentBuilderSetting.namespaceAware
54        };
55        DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
56        setFactory(testFactory);
57
58    //
59    //   check if loaded documents are supported for content type
60    //
61    String contentType = getContentType();
62    preload(contentType, "staffNS", true);
63    }
64
65   /**
66    * Runs the test case.
67    * @throws Throwable Any uncaught exception causes test to fail
68    */
69   public void runTest() throws Throwable {
70      Document doc;
71      NamedNodeMap attributes;
72      Node element;
73      Attr attribute;
74      Attr attributeRemoved;
75      NodeList elementList;
76      doc = (Document) load("staffNS", true);
77      elementList = doc.getElementsByTagNameNS("*", "employee");
78      element = elementList.item(0);
79      attributes = element.getAttributes();
80      attributeRemoved = (Attr) attributes.removeNamedItemNS("http://www.w3.org/2000/xmlns/", "xmlns");
81      attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/2000/xmlns/", "xmlns");
82      assertNull("namednodemapremovenameditemns04_1", attribute);
83      attributeRemoved = (Attr) attributes.removeNamedItemNS("http://www.w3.org/2000/xmlns/", "dmstc");
84      attribute = (Attr) attributes.getNamedItemNS("http://www.w3.org/2000/xmlns/", "dmstc");
85      assertNull("namednodemapremovenameditemns04_2", attribute);
86      }
87   /**
88    *  Gets URI that identifies the test.
89    *  @return uri identifier of test
90    */
91   public String getTargetURI() {
92      return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/namednodemapremovenameditemns04";
93   }
94   /**
95    * Runs this test from the command line.
96    * @param args command line arguments
97    */
98   public static void main(final String[] args) {
99        DOMTestCase.doMain(namednodemapremovenameditemns04.class, args);
100   }
101}
102
103