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.
16See W3C License http://www.w3.org/Consortium/Legal/ for more details.
17
18*/
19
20package org.w3c.domts.level1.core;
21
22import org.w3c.dom.*;
23
24
25import org.w3c.domts.DOMTestCase;
26import org.w3c.domts.DOMTestDocumentBuilderFactory;
27
28
29
30/**
31 *     The "getNodeType()" method for a CDATASection Node
32 *     returns the constant value 4.
33 *
34 *     Retrieve the CDATASection node contained inside the
35 *     second child of the second employee and invoke the
36 *     "getNodeType()" method.   The method should return 4.
37* @author NIST
38* @author Mary Brady
39* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558</a>
40* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212</a>
41*/
42public final class nodecdatasectionnodetype 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 nodecdatasectionnodetype(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.notCoalescing
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, "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      NodeList elementList;
72      Element testName;
73      Node cdataNode;
74      int nodeType;
75      doc = (Document) load("staff", false);
76      elementList = doc.getElementsByTagName("name");
77      testName = (Element) elementList.item(1);
78      cdataNode = testName.getLastChild();
79      nodeType = (int) cdataNode.getNodeType();
80
81      if (equals(3, nodeType)) {
82          cdataNode = doc.createCDATASection("");
83      nodeType = (int) cdataNode.getNodeType();
84      }
85    assertEquals("nodeTypeCDATA", 4, nodeType);
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/level1/core/nodecdatasectionnodetype";
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(nodecdatasectionnodetype.class, args);
100   }
101}
102
103