1 7 8 package org.netbeans.modules.xml.xdm.nodes; 9 10 import junit.framework.*; 11 import org.netbeans.modules.xml.xdm.Util; 12 import org.netbeans.modules.xml.xdm.XDMModel; 13 14 18 public class DocumentTest extends TestCase { 19 20 public DocumentTest(String testName) { 21 super(testName); 22 } 23 24 protected void setUp() throws Exception { 25 xmlModel = Util.loadXDMModel("nodes/xdm.xml"); 26 xmlModel.sync(); 27 doc = xmlModel.getDocument(); 28 } 29 30 public static Test suite() { 31 TestSuite suite = new TestSuite(DocumentTest.class); 32 33 return suite; 34 } 35 36 39 public void testGetNodeType() { 40 41 short expResult = org.w3c.dom.Node.DOCUMENT_NODE; 42 short result = doc.getNodeType(); 43 assertEquals("getNodeType must return DOCUMENT_NODE",expResult, result); 44 } 45 46 49 public void testGetNodeName() { 50 51 String expResult = "#document"; 52 String result = doc.getNodeName(); 53 assertEquals("getNodeName must return #document",expResult, result); 54 } 55 56 59 public void testCreateElement() { 60 61 String tagName = "newElement"; 62 org.w3c.dom.Element result = doc.createElement(tagName); 63 assertEquals(tagName, result.getTagName()); 64 } 65 66 69 public void testCreateAttribute() { 70 71 String name = "attrName"; 72 org.w3c.dom.Attr result = doc.createAttribute(name); 73 assertEquals(name, result.getName()); 74 } 75 76 79 public void testCreateElementNS() { 80 81 String namespaceURI = ""; 82 String qualifiedName = "xs:element"; 83 org.w3c.dom.Element result = doc.createElementNS(namespaceURI, qualifiedName); 84 assertEquals("element", result.getLocalName()); 85 assertEquals("xs", result.getPrefix()); 86 } 87 88 91 public void testCreateAttributeNS() { 92 93 String namespaceURI = ""; 94 String qualifiedName = "xs:attribute"; 95 org.w3c.dom.Attr result = doc.createAttributeNS(namespaceURI, qualifiedName); 96 assertEquals("attribute", result.getLocalName()); 97 assertEquals("xs", result.getPrefix()); 98 } 99 100 103 public void testGetDocumentElement() { 104 105 Element expResult = (Element)doc.getChildNodes().item(0); 106 Element result = (Element)doc.getDocumentElement(); 107 assertNotNull(result); 108 assertEquals(expResult, result); 109 } 110 111 114 public void testGetXmlVersion() { 115 116 String expResult = "1.0"; 117 String result = doc.getXmlVersion(); 118 assertEquals(expResult, result); 119 } 120 121 124 public void testGetXmlEncoding() { 125 126 String expResult = "UTF-8"; 127 String result = doc.getXmlEncoding(); 128 assertEquals(expResult, result); 129 } 130 131 134 public void testGetXmlStandalone() { 135 136 boolean expResult = false; 137 boolean result = doc.getXmlStandalone(); 138 assertEquals(expResult, result); 139 } 140 141 private XDMModel xmlModel; 142 private Document doc; 143 } 144 | Popular Tags |