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