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 *     If the sum of the offset and count used in the
32 *    "deleteData(offset,count) method is greater than the
33 *    length of the character data then all the characters
34 *    from the offset to the end of the data are deleted.
35 *
36 *    Retrieve the character data from the last child of the
37 *    first employee.  The "deleteData(offset,count)"
38 *    method is then called with offset=4 and count=50.
39 *    The method should delete the characters from position 4
40 *    to the end of the data since the offset+count(50+4)
41 *    is greater than the length of the character data(35).
42 *    The new value of the character data should be "1230".
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-7C603781">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781</a>
47*/
48public final class characterdatadeletedataexceedslength extends DOMTestCase {
49
50   /**
51    * Constructor.
52    * @param factory document factory, may not be null
53    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
54    */
55   public characterdatadeletedataexceedslength(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
56      super(factory);
57
58    //
59    //   check if loaded documents are supported for content type
60    //
61    String contentType = getContentType();
62    preload(contentType, "staff", true);
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      Node nameNode;
73      CharacterData child;
74      String childData;
75      doc = (Document) load("staff", true);
76      elementList = doc.getElementsByTagName("address");
77      nameNode = elementList.item(0);
78      child = (CharacterData) nameNode.getFirstChild();
79      child.deleteData(4, 50);
80      childData = child.getData();
81      assertEquals("characterdataDeleteDataExceedsLengthAssert", "1230", childData);
82      }
83   /**
84    *  Gets URI that identifies the test.
85    *  @return uri identifier of test
86    */
87   public String getTargetURI() {
88      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedataexceedslength";
89   }
90   /**
91    * Runs this test from the command line.
92    * @param args command line arguments
93    */
94   public static void main(final String[] args) {
95        DOMTestCase.doMain(characterdatadeletedataexceedslength.class, args);
96   }
97}
98
99