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.
16
17See W3C License http://www.w3.org/Consortium/Legal/ for more details.
18
19*/
20
21package org.w3c.domts.level2.core;
22
23import org.w3c.dom.*;
24
25
26import org.w3c.domts.DOMTestCase;
27import org.w3c.domts.DOMTestDocumentBuilderFactory;
28
29
30
31/**
32 *   The "getOwnerElement()" will return the Element node this attribute is attached to or
33 *   null if this attribute is not in use.
34 *   Import an attribute node to another document.  If an Attr node is imported, its
35 *   ownerElement attribute should be set to null.  Verify if the ownerElement has been set
36 *   to null.
37* @author IBM
38* @author Neil Delima
39* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement">http://www.w3.org/TR/DOM-Level-2-Core/core#Attr-ownerElement</a>
40*/
41public final class attrgetownerelement04 extends DOMTestCase {
42
43   /**
44    * Constructor.
45    * @param factory document factory, may not be null
46    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
47    */
48   public attrgetownerelement04(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
49
50      org.w3c.domts.DocumentBuilderSetting[] settings =
51          new org.w3c.domts.DocumentBuilderSetting[] {
52org.w3c.domts.DocumentBuilderSetting.namespaceAware
53        };
54        DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
55        setFactory(testFactory);
56
57    //
58    //   check if loaded documents are supported for content type
59    //
60    String contentType = getContentType();
61    preload(contentType, "staffNS", false);
62    preload(contentType, "staff", false);
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      Document docImp;
72      Node ownerElement;
73      Element element;
74      Attr attr;
75      Attr attrImp;
76      NodeList addresses;
77      doc = (Document) load("staffNS", false);
78      docImp = (Document) load("staff", false);
79      addresses = doc.getElementsByTagNameNS("http://www.nist.gov", "address");
80      element = (Element) addresses.item(1);
81      assertNotNull("empAddressNotNull", element);
82      attr = element.getAttributeNodeNS("http://www.nist.gov", "zone");
83      attrImp = (Attr) docImp.importNode(attr, true);
84      ownerElement = attrImp.getOwnerElement();
85      assertNull("attrgetownerelement04", ownerElement);
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/attrgetownerelement04";
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(attrgetownerelement04.class, args);
100   }
101}
102
103