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 "deleteData(offset,count)" method raises a NO_MODIFICATION_ALLOWED_ERR
32 *    DOMException if the node is readonly.
33 *    Obtain the children of the THIRD "gender" element.  The elements
34 *    content is an entity reference.  Get the FIRST item
35 *    from the entity reference and execute the "deleteData(offset,count)" method.
36 *    This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
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#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])</a>
40* @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>
41* @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])</a>
42* @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>
43*/
44public final class characterdatadeletedatanomodificationallowederr extends DOMTestCase {
45
46   /**
47    * Constructor.
48    * @param factory document factory, may not be null
49    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
50    */
51   public characterdatadeletedatanomodificationallowederr(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
52      super(factory);
53
54    //
55    //   check if loaded documents are supported for content type
56    //
57    String contentType = getContentType();
58    preload(contentType, "staff", true);
59    }
60
61   /**
62    * Runs the test case.
63    * @throws Throwable Any uncaught exception causes test to fail
64    */
65   public void runTest() throws Throwable {
66      Document doc;
67      NodeList genderList;
68      Node genderNode;
69      Node entElement;
70      Node entElementContent;
71      int nodeType;
72      Node entReference;
73      doc = (Document) load("staff", true);
74      genderList = doc.getElementsByTagName("gender");
75      genderNode = genderList.item(2);
76      entReference = genderNode.getFirstChild();
77      assertNotNull("entReferenceNotNull", entReference);
78      nodeType = (int) entReference.getNodeType();
79
80      if (equals(3, nodeType)) {
81          entReference = doc.createEntityReference("ent4");
82      assertNotNull("createdEntRefNotNull", entReference);
83      }
84    entElement = entReference.getFirstChild();
85      assertNotNull("entElementNotNull", entElement);
86      entElementContent = entElement.getFirstChild();
87      assertNotNull("entElementContentNotNull", entElementContent);
88
89      {
90         boolean success = false;
91         try {
92            ((CharacterData) /*Node */entElementContent).deleteData(1, 3);
93          } catch (DOMException ex) {
94            success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
95         }
96         assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success);
97      }
98}
99   /**
100    *  Gets URI that identifies the test.
101    *  @return uri identifier of test
102    */
103   public String getTargetURI() {
104      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatanomodificationallowederr";
105   }
106   /**
107    * Runs this test from the command line.
108    * @param args command line arguments
109    */
110   public static void main(final String[] args) {
111        DOMTestCase.doMain(characterdatadeletedatanomodificationallowederr.class, args);
112   }
113}
114
115