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