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  *     The "appendData(arg)" 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 "appendData(arg)" 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-32791A2F">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F</a>
     41 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-32791A2F')/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-32791A2F')/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-32791A2F">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F</a>
     43 */
     44 public final class characterdataappenddatanomodificationallowederr 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 characterdataappenddatanomodificationallowederr(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       Node entReference;
     72       int nodeType;
     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(1, 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).appendData("newString");
     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/characterdataappenddatanomodificationallowederr";
    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(characterdataappenddatanomodificationallowederr.class, args);
    112    }
    113 }
    114 
    115