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 Copyright (c) 2001-2004 World Wide Web Consortium,
      9 (Massachusetts Institute of Technology, Institut National de
     10 Recherche en Informatique et en Automatique, Keio University). All
     11 Rights Reserved. This program is distributed under the W3C's Software
     12 Intellectual Property License. This program is distributed in the
     13 hope that it will be useful, but WITHOUT ANY WARRANTY; without even
     14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     15 PURPOSE.
     16 See W3C License http://www.w3.org/Consortium/Legal/ for more details.
     17 
     18 */
     19 
     20 package org.w3c.domts.level1.core;
     21 
     22 import org.w3c.dom.*;
     23 
     24 
     25 import org.w3c.domts.DOMTestCase;
     26 import org.w3c.domts.DOMTestDocumentBuilderFactory;
     27 
     28 
     29 
     30 /**
     31  * Retrieve the last CDATASection node located inside the
     32  * second child of the second employee and examine its
     33  * content.  Since the CDATASection interface inherits
     34  * from the CharacterData interface(via the Text node),
     35  * the "getData()" method can be used to access the
     36  * CDATA content.
     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-72AB8359">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359</a>
     40 */
     41 public final class cdatasectiongetdata 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 cdatasectiongetdata(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
     49 
     50       org.w3c.domts.DocumentBuilderSetting[] settings =
     51           new org.w3c.domts.DocumentBuilderSetting[] {
     52 org.w3c.domts.DocumentBuilderSetting.notCoalescing
     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, "staff", false);
     62     }
     63 
     64    /**
     65     * Runs the test case.
     66     * @throws Throwable Any uncaught exception causes test to fail
     67     */
     68    public void runTest() throws Throwable {
     69       Document doc;
     70       NodeList nameList;
     71       Node child;
     72       Node lastChild;
     73       String data;
     74       int nodeType;
     75       doc = (Document) load("staff", false);
     76       nameList = doc.getElementsByTagName("name");
     77       child = nameList.item(1);
     78       lastChild = child.getLastChild();
     79       nodeType = (int) lastChild.getNodeType();
     80       assertEquals("isCDATA", 4, nodeType);
     81       data = ((CharacterData) /*Node */lastChild).getData();
     82       assertEquals("data", "This is an adjacent CDATASection with a reference to a tab &tab;", data);
     83       }
     84    /**
     85     *  Gets URI that identifies the test.
     86     *  @return uri identifier of test
     87     */
     88    public String getTargetURI() {
     89       return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/cdatasectiongetdata";
     90    }
     91    /**
     92     * Runs this test from the command line.
     93     * @param args command line arguments
     94     */
     95    public static void main(final String[] args) {
     96         DOMTestCase.doMain(cdatasectiongetdata.class, args);
     97    }
     98 }
     99 
    100