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 "createEntityReference(tagName)" method raises an 32 * INVALID_CHARACTER_ERR DOMException if the specified 33 * tagName contains an invalid character. 34 * @author NIST 35 * @author Mary Brady 36 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])</a> 37 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE</a> 38 * @see <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-392B75AE')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])">http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-392B75AE')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])</a> 39 * @see <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=249">http://www.w3.org/Bugs/Public/show_bug.cgi?id=249</a> 40 */ 41 public final class documentinvalidcharacterexceptioncreateentref 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 */ documentinvalidcharacterexceptioncreateentref(final DOMTestDocumentBuilderFactory factory)48 public documentinvalidcharacterexceptioncreateentref(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 49 super(factory); 50 if (factory.hasFeature("XML", null) != true) { 51 throw org.w3c.domts.DOMTestIncompatibleException.incompatibleFeature("XML", null); 52 } 53 54 // 55 // check if loaded documents are supported for content type 56 // 57 String contentType = getContentType(); 58 preload(contentType, "hc_staff", true); 59 } 60 61 /** 62 * Runs the test case. 63 * @throws Throwable Any uncaught exception causes test to fail 64 */ runTest()65 public void runTest() throws Throwable { 66 Document doc; 67 EntityReference badEntityRef; 68 doc = (Document) load("hc_staff", true); 69 70 if (("text/html".equals(getContentType()))) { 71 72 { 73 boolean success = false; 74 try { 75 badEntityRef = doc.createEntityReference("foo"); 76 } catch (DOMException ex) { 77 success = (ex.code == DOMException.NOT_SUPPORTED_ERR); 78 } 79 assertTrue("throw_NOT_SUPPORTED_ERR", success); 80 } 81 } else { 82 83 { 84 boolean success = false; 85 try { 86 badEntityRef = doc.createEntityReference("invalid^Name"); 87 } catch (DOMException ex) { 88 success = (ex.code == DOMException.INVALID_CHARACTER_ERR); 89 } 90 assertTrue("throw_INVALID_CHARACTER_ERR", success); 91 } 92 } 93 94 } 95 /** 96 * Gets URI that identifies the test. 97 * @return uri identifier of test 98 */ getTargetURI()99 public String getTargetURI() { 100 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/documentinvalidcharacterexceptioncreateentref"; 101 } 102 /** 103 * Runs this test from the command line. 104 * @param args command line arguments 105 */ main(final String[] args)106 public static void main(final String[] args) { 107 DOMTestCase.doMain(documentinvalidcharacterexceptioncreateentref.class, args); 108 } 109 } 110 111