1 /* 2 This Java source file was generated by test-to-java.xsl 3 and is a derived work from the source document. 4 The source document contained the following notice: 5 6 7 Copyright (c) 2004 World Wide Web Consortium, 8 (Massachusetts Institute of Technology, Institut National de 9 Recherche en Informatique et en Automatique, Keio University). All 10 Rights Reserved. This program is distributed under the W3C's Software 11 Intellectual Property License. This program is distributed in the 12 hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 PURPOSE. 15 See W3C License http://www.w3.org/Consortium/Legal/ for more details. 16 17 */ 18 19 package tests.org.w3c.dom; 20 21 import org.w3c.dom.NamedNodeMap; 22 import org.w3c.dom.Document; 23 import org.w3c.dom.DocumentType; 24 import org.w3c.dom.DOMException; 25 26 import javax.xml.parsers.DocumentBuilder; 27 28 /** 29 * An attempt to add remove an notation using removeNamedItemNS should result in 30 * a NO_MODIFICATION_ERR or a NOT_FOUND_ERR. 31 * 32 * @author Curt Arnold 33 * @see <a 34 * href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D46829EF">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-D46829EF</a> 35 * @see <a 36 * href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-removeNamedItemNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-removeNamedItemNS</a> 37 */ 38 public final class HCNotationsRemoveNamedItemNS extends DOMTestCase { 39 40 DOMDocumentBuilderFactory factory; 41 42 DocumentBuilder builder; 43 setUp()44 protected void setUp() throws Exception { 45 super.setUp(); 46 try { 47 factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory 48 .getConfiguration1()); 49 builder = factory.getBuilder(); 50 } catch (Exception e) { 51 fail("Unexpected exception" + e.getMessage()); 52 } 53 } 54 tearDown()55 protected void tearDown() throws Exception { 56 factory = null; 57 builder = null; 58 super.tearDown(); 59 } 60 61 /** 62 * Runs the test case. 63 * 64 * @throws Throwable 65 * Any uncaught exception causes test to fail 66 */ testRemoveNamedItemNS()67 public void testRemoveNamedItemNS() throws Throwable { 68 Document doc; 69 NamedNodeMap notations; 70 DocumentType docType; 71 72 doc = (Document) load("hc_staff", builder); 73 docType = doc.getDoctype(); 74 75 if (!(("text/html".equals(getContentType())))) { 76 assertNotNull("docTypeNotNull", docType); 77 notations = docType.getNotations(); 78 assertNotNull("notationsNotNull", notations); 79 80 try { 81 notations.removeNamedItemNS("http://www.w3.org/1999/xhtml", 82 "alpha"); 83 fail("throw_NO_MOD_OR_NOT_FOUND_ERR"); 84 85 } catch (DOMException ex) { 86 switch (ex.code) { 87 case 7: 88 break; 89 case 8: 90 break; 91 default: 92 throw ex; 93 } 94 } 95 } 96 } 97 98 } 99