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 8 9 10 11Copyright (c) 2001 World Wide Web Consortium, 12 13(Massachusetts Institute of Technology, Institut National de 14 15Recherche en Informatique et en Automatique, Keio University). All 16 17Rights Reserved. This program is distributed under the W3C's Software 18 19Intellectual Property License. This program is distributed in the 20 21hope that it will be useful, but WITHOUT ANY WARRANTY; without even 22 23the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 24 25PURPOSE. 26 27 28 29See W3C License http://www.w3.org/Consortium/Legal/ for more details. 30 31 32 33 34*/ 35 36package org.w3c.domts.level2.core; 37 38import org.w3c.dom.*; 39 40 41import org.w3c.domts.DOMTestCase; 42import org.w3c.domts.DOMTestDocumentBuilderFactory; 43 44 45 46/** 47 * The method createDocumentType should raise a INVALID_CHARACTER_ERR if the qualifiedName 48 * contains an illegal characters. 49 * 50 * Invoke createDocument on this DOMImplementation with qualifiedNames having illegal characters. 51 * Check if an INVALID_CHARACTER_ERR is raised in each case. 52* @author IBM 53* @author Neil Delima 54* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType">http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType</a> 55*/ 56public final class domimplementationcreatedocumenttype04 extends DOMTestCase { 57 58 /** 59 * Constructor. 60 * @param factory document factory, may not be null 61 * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration 62 */ 63 public domimplementationcreatedocumenttype04(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { 64 super(factory); 65 66 // 67 // check if loaded documents are supported for content type 68 // 69 String contentType = getContentType(); 70 preload(contentType, "staffNS", false); 71 } 72 73 /** 74 * Runs the test case. 75 * @throws Throwable Any uncaught exception causes test to fail 76 */ 77 public void runTest() throws Throwable { 78 Document doc; 79 DOMImplementation domImpl; 80 DocumentType newDocType; 81 String publicId = "http://www.w3.org/DOM/Test/dom2.dtd"; 82 String systemId = "dom2.dtd"; 83 String qualifiedName; 84 java.util.List qualifiedNames = new java.util.ArrayList(); 85 qualifiedNames.add("{"); 86 qualifiedNames.add("}"); 87 qualifiedNames.add("'"); 88 qualifiedNames.add("~"); 89 qualifiedNames.add("`"); 90 qualifiedNames.add("@"); 91 qualifiedNames.add("#"); 92 qualifiedNames.add("$"); 93 qualifiedNames.add("%"); 94 qualifiedNames.add("^"); 95 qualifiedNames.add("&"); 96 qualifiedNames.add("*"); 97 qualifiedNames.add("("); 98 qualifiedNames.add(")"); 99 100 doc = (Document) load("staffNS", false); 101 domImpl = doc.getImplementation(); 102 for (int indexN10073 = 0; indexN10073 < qualifiedNames.size(); indexN10073++) { 103 qualifiedName = (String) qualifiedNames.get(indexN10073); 104 105 { 106 boolean success = false; 107 try { 108 newDocType = domImpl.createDocumentType(qualifiedName, publicId, systemId); 109 } catch (DOMException ex) { 110 success = (ex.code == DOMException.INVALID_CHARACTER_ERR); 111 } 112 assertTrue("domimplementationcreatedocumenttype04", success); 113 } 114 } 115 } 116 /** 117 * Gets URI that identifies the test. 118 * @return uri identifier of test 119 */ 120 public String getTargetURI() { 121 return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/domimplementationcreatedocumenttype04"; 122 } 123 /** 124 * Runs this test from the command line. 125 * @param args command line arguments 126 */ 127 public static void main(final String[] args) { 128 DOMTestCase.doMain(domimplementationcreatedocumenttype04.class, args); 129 } 130} 131 132