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 
      9 Copyright (c) 2001-2004 World Wide Web Consortium,
     10 (Massachusetts Institute of Technology, Institut National de
     11 Recherche en Informatique et en Automatique, Keio University).  All
     12 Rights Reserved.  This program is distributed under the W3C's Software
     13 Intellectual Property License.  This program is distributed in the
     14 hope that it will be useful, but WITHOUT ANY WARRANTY; without even
     15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     16 PURPOSE.
     17 
     18 See W3C License http://www.w3.org/Consortium/Legal/ for more details.
     19 
     20 
     21 */
     22 
     23 package org.w3c.domts.level2.core;
     24 
     25 import org.w3c.dom.*;
     26 
     27 
     28 import org.w3c.domts.DOMTestCase;
     29 import org.w3c.domts.DOMTestDocumentBuilderFactory;
     30 
     31 
     32 
     33 /**
     34  *  The method setPrefix raises a NAMESPACE_ERR if the namespaceURI of this node is null.
     35  *
     36  *  Create a new element node without a namespace prefix.  Call setPrefix on the newly created elemenent node.
     37  *  Check if a NAMESPACE_ERR is thrown.
     38 * @author IBM
     39 * @author Neil Delima
     40 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-NodeNSPrefix</a>
     41 */
     42 public final class nodesetprefix03 extends DOMTestCase {
     43 
     44    /**
     45     * Constructor.
     46     * @param factory document factory, may not be null
     47     * @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
     48     */
     49    public nodesetprefix03(final DOMTestDocumentBuilderFactory factory)  throws org.w3c.domts.DOMTestIncompatibleException {
     50 
     51       org.w3c.domts.DocumentBuilderSetting[] settings =
     52           new org.w3c.domts.DocumentBuilderSetting[] {
     53 org.w3c.domts.DocumentBuilderSetting.namespaceAware
     54         };
     55         DOMTestDocumentBuilderFactory testFactory = factory.newInstance(settings);
     56         setFactory(testFactory);
     57 
     58     //
     59     //   check if loaded documents are supported for content type
     60     //
     61     String contentType = getContentType();
     62     preload(contentType, "staffNS", true);
     63     }
     64 
     65    /**
     66     * Runs the test case.
     67     * @throws Throwable Any uncaught exception causes test to fail
     68     */
     69    public void runTest() throws Throwable {
     70       Document doc;
     71       Element element;
     72       doc = (Document) load("staffNS", true);
     73       element = doc.createElement("address");
     74 
     75       {
     76          boolean success = false;
     77          try {
     78             element.setPrefix("test");
     79           } catch (DOMException ex) {
     80             success = (ex.code == DOMException.NAMESPACE_ERR);
     81          }
     82          assertTrue("throw_NAMESPACE_ERR", success);
     83       }
     84 }
     85    /**
     86     *  Gets URI that identifies the test.
     87     *  @return uri identifier of test
     88     */
     89    public String getTargetURI() {
     90       return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/nodesetprefix03";
     91    }
     92    /**
     93     * Runs this test from the command line.
     94     * @param args command line arguments
     95     */
     96    public static void main(final String[] args) {
     97         DOMTestCase.doMain(nodesetprefix03.class, args);
     98    }
     99 }
    100 
    101