1 package tests.org.w3c.dom; 2 3 import javax.xml.parsers.DocumentBuilder; 4 5 import org.w3c.dom.DOMException; 6 import org.w3c.dom.Document; 7 import org.w3c.dom.DocumentType; 8 import org.w3c.dom.Element; 9 import org.w3c.dom.NamedNodeMap; 10 11 /** 12 * An attempt to add an element to the named node map returned by entities 13 * should result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR. 14 * 15 * @author Curt Arnold 16 * @see <a 17 * href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1788794630">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-1788794630</a> 18 * @see <a 19 * href="http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS">http://www.w3.org/TR/DOM-Level-2-Core/core#ID-setNamedItemNS</a> 20 */ 21 public final class HCEntitiesSetNamedItemNS extends DOMTestCase { 22 23 DOMDocumentBuilderFactory factory; 24 25 DocumentBuilder builder; 26 setUp()27 protected void setUp() throws Exception { 28 super.setUp(); 29 try { 30 factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory 31 .getConfiguration1()); 32 builder = factory.getBuilder(); 33 } catch (Exception e) { 34 fail("Unexpected exception" + e.getMessage()); 35 } 36 } 37 tearDown()38 protected void tearDown() throws Exception { 39 factory = null; 40 builder = null; 41 super.tearDown(); 42 } 43 44 /** 45 * Runs the test case. 46 * 47 * @throws Throwable 48 * Any uncaught exception causes test to fail 49 */ 50 // Assumes validation. 51 // public void testSetNamedItemNS() throws Throwable { 52 // Document doc; 53 // NamedNodeMap entities; 54 // DocumentType docType; 55 // 56 // Element elem; 57 // doc = (Document) load("hc_staff", builder); 58 // docType = doc.getDoctype(); 59 // 60 // if (!(("text/html".equals(getContentType())))) { 61 // assertNotNull("docTypeNotNull", docType); 62 // entities = docType.getEntities(); 63 // assertNotNull("entitiesNotNull", entities); 64 // elem = doc.createElementNS("http://www.w3.org/1999/xhtml", "br"); 65 // 66 // try { 67 // entities.setNamedItemNS(elem); 68 // fail("throw_HIER_OR_NO_MOD_ERR"); 69 // 70 // } catch (DOMException ex) { 71 // switch (ex.code) { 72 // case 3: 73 // break; 74 // case 7: 75 // break; 76 // default: 77 // throw ex; 78 // } 79 // } 80 // } 81 // } 82 83 } 84