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-2004 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 importNode method imports a node from another document to this document.
35 *  The returned node has no parent; (parentNode is null). The source node is not
36 *  altered or removed from the original document but a new copy of the source node
37 *  is created.
38 *
39 *  Using the method importNode with deep=true/false, import two notaiton nodes into the
40 *  same and different documnet objects.  In each case check if valid public and systemids
41 *  are returned if any and if none, check if a null value was returned.
42* @author IBM
43* @author Neil Delima
44* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core">http://www.w3.org/TR/DOM-Level-2-Core/core</a>
45* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode">http://www.w3.org/TR/DOM-Level-2-Core/core#Core-Document-importNode</a>
46*/
47public final class documentimportnode22 extends DOMTestCase {
48
49   /**
50    * Constructor.
51    * @param factory document factory, may not be null
52    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
53    */
54   public documentimportnode22(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
55
56      org.w3c.domts.DocumentBuilderSetting[] settings =
57          new org.w3c.domts.DocumentBuilderSetting[] {
58org.w3c.domts.DocumentBuilderSetting.namespaceAware
59        };
60        DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
61        setFactory(testFactory);
62
63    //
64    //   check if loaded documents are supported for content type
65    //
66    String contentType = getContentType();
67    preload(contentType, "staffNS", true);
68    }
69
70   /**
71    * Runs the test case.
72    * @throws Throwable Any uncaught exception causes test to fail
73    */
74   public void runTest() throws Throwable {
75      Document doc;
76      DocumentType docTypeNull = null;
77
78      Document docImp;
79      DOMImplementation domImpl;
80      DocumentType docType;
81      NamedNodeMap nodeMap;
82      Notation notation1;
83      Notation notation2;
84      Notation notationImp1;
85      Notation notationImp2;
86      Notation notationImpNew1;
87      Notation notationImpNew2;
88      String publicId1;
89      String publicId1Imp;
90      String publicId1NewImp;
91      String publicId2Imp;
92      String publicId2NewImp;
93      String systemId1Imp;
94      String systemId1NewImp;
95      String systemId2;
96      String systemId2Imp;
97      String systemId2NewImp;
98      doc = (Document) load("staffNS", true);
99      domImpl = doc.getImplementation();
100      docType = doc.getDoctype();
101      docImp = domImpl.createDocument("http://www.w3.org/DOM/Test", "a:b", docTypeNull);
102      nodeMap = docType.getNotations();
103      assertNotNull("notationsNotNull", nodeMap);
104      notation1 = (Notation) nodeMap.getNamedItem("notation1");
105      notation2 = (Notation) nodeMap.getNamedItem("notation2");
106      notationImp1 = (Notation) doc.importNode(notation1, true);
107      notationImp2 = (Notation) doc.importNode(notation2, false);
108      notationImpNew1 = (Notation) docImp.importNode(notation1, false);
109      notationImpNew2 = (Notation) docImp.importNode(notation2, true);
110      publicId1 = notation1.getPublicId();
111      publicId1Imp = notation1.getPublicId();
112      publicId1NewImp = notation1.getPublicId();
113      systemId1Imp = notation1.getSystemId();
114      systemId1NewImp = notation1.getSystemId();
115      publicId2Imp = notation2.getPublicId();
116      publicId2NewImp = notation2.getPublicId();
117      systemId2 = notation2.getSystemId();
118      systemId2Imp = notation2.getSystemId();
119      systemId2NewImp = notation2.getSystemId();
120      assertEquals("documentimportnode22_N1PID", publicId1, publicId1Imp);
121      assertEquals("documentimportnode22_N1NPID", publicId1, publicId1NewImp);
122      assertNull("documentimportnode22_N1SID", systemId1Imp);
123      assertNull("documentimportnode22_N1NSID", systemId1NewImp);
124      assertEquals("documentimportnode22_N2SID", systemId2, systemId2Imp);
125      assertEquals("documentimportnode22_N2NSID", systemId2, systemId2NewImp);
126      assertNull("documentimportnode22_N2PID", publicId2Imp);
127      assertNull("documentimportnode22_N2NPID", publicId2Imp);
128      }
129   /**
130    *  Gets URI that identifies the test.
131    *  @return uri identifier of test
132    */
133   public String getTargetURI() {
134      return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentimportnode22";
135   }
136   /**
137    * Runs this test from the command line.
138    * @param args command line arguments
139    */
140   public static void main(final String[] args) {
141        DOMTestCase.doMain(documentimportnode22.class, args);
142   }
143}
144
145