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 createAttributeNS raises an INVALID_CHARACTER_ERR if the specified
48 *  qualified name contains an illegal character
49 *
50 *  Invoke the createAttributeNS method on this Document object with a valid value for
51 *  namespaceURI, and qualifiedNames that contain illegal characters.  Check if the an
52 *  INVALID_CHARACTER_ERR was thrown.
53* @author IBM
54* @author Neil Delima
55* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core">http://www.w3.org/TR/DOM-Level-2-Core/core</a>
56* @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>
57*/
58public final class documentcreateattributeNS03 extends DOMTestCase {
59
60   /**
61    * Constructor.
62    * @param factory document factory, may not be null
63    * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
64    */
65   public documentcreateattributeNS03(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
66      super(factory);
67
68    //
69    //   check if loaded documents are supported for content type
70    //
71    String contentType = getContentType();
72    preload(contentType, "staffNS", false);
73    }
74
75   /**
76    * Runs the test case.
77    * @throws Throwable Any uncaught exception causes test to fail
78    */
79   public void runTest() throws Throwable {
80      Document doc;
81      Attr attribute;
82      String namespaceURI = "http://www.w3.org/DOM/Test/Level2";
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
95      doc = (Document) load("staffNS", false);
96      for (int indexN1005A = 0; indexN1005A < qualifiedNames.size(); indexN1005A++) {
97          qualifiedName = (String) qualifiedNames.get(indexN1005A);
98
99      {
100         boolean success = false;
101         try {
102            attribute = doc.createAttributeNS(namespaceURI, qualifiedName);
103          } catch (DOMException ex) {
104            success = (ex.code == DOMException.INVALID_CHARACTER_ERR);
105         }
106         assertTrue("documentcreateattributeNS03", success);
107      }
108  }
109      }
110   /**
111    *  Gets URI that identifies the test.
112    *  @return uri identifier of test
113    */
114   public String getTargetURI() {
115      return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/documentcreateattributeNS03";
116   }
117   /**
118    * Runs this test from the command line.
119    * @param args command line arguments
120    */
121   public static void main(final String[] args) {
122        DOMTestCase.doMain(documentcreateattributeNS03.class, args);
123   }
124}
125
126