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 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 *     On successful invocation of the "deleteData(offset,count)"
32 *    method, the "getData()" and "getLength()" methods reflect
33 *    the changes.
34 *
35 *    Retrieve the character data from the last child of the
36 *    first employee.  The "deleteData(offset,count)"
37 *    method is then called with offset=30 and count=5.
38 *    The method should delete the characters from position
39 *    30 thru position 35.  The new value of the character data
40 *    should be "1230 North Ave. Dallas, Texas" which is
41 *    returned by the "getData()" method and "getLength()"
42 *    method should return 30".
43* @author NIST
44* @author Mary Brady
45* @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>
46* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C</a>
47* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781</a>
48*/
49public final class characterdatadeletedatagetlengthanddata extends DOMTestCase {
50
51   /**
52    * Constructor.
53    * @param factory document factory, may not be null
54    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
55    */
56   public characterdatadeletedatagetlengthanddata(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
57      super(factory);
58
59    //
60    //   check if loaded documents are supported for content type
61    //
62    String contentType = getContentType();
63    preload(contentType, "staff", true);
64    }
65
66   /**
67    * Runs the test case.
68    * @throws Throwable Any uncaught exception causes test to fail
69    */
70   public void runTest() throws Throwable {
71      Document doc;
72      NodeList elementList;
73      Node nameNode;
74      CharacterData child;
75      String childData;
76      int childLength;
77      java.util.List result = new java.util.ArrayList();
78
79      doc = (Document) load("staff", true);
80      elementList = doc.getElementsByTagName("address");
81      nameNode = elementList.item(0);
82      child = (CharacterData) nameNode.getFirstChild();
83      child.deleteData(30, 5);
84      childData = child.getData();
85      assertEquals("data", "1230 North Ave. Dallas, Texas ", childData);
86      childLength = (int) child.getLength();
87      assertEquals("length", 30, childLength);
88      }
89   /**
90    *  Gets URI that identifies the test.
91    *  @return uri identifier of test
92    */
93   public String getTargetURI() {
94      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatagetlengthanddata";
95   }
96   /**
97    * Runs this test from the command line.
98    * @param args command line arguments
99    */
100   public static void main(final String[] args) {
101        DOMTestCase.doMain(characterdatadeletedatagetlengthanddata.class, args);
102   }
103}
104
105