KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xdm > nodes > DocumentTest


1 /*
2  * DocumentTest.java
3  * JUnit based test
4  *
5  * Created on October 21, 2005, 2:21 PM
6  */

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 /**
15  *
16  * @author ajit
17  */

18 public class DocumentTest extends TestCase {
19     
20     public DocumentTest(String JavaDoc testName) {
21         super(testName);
22     }
23
24     protected void setUp() throws Exception JavaDoc {
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     /**
37      * Test of getNodeType method, of class org.netbeans.modules.xml.xdm.nodes.Document.
38      */

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     /**
47      * Test of getNodeName method, of class org.netbeans.modules.xml.xdm.nodes.Document.
48      */

49     public void testGetNodeName() {
50         
51         String JavaDoc expResult = "#document";
52         String JavaDoc result = doc.getNodeName();
53         assertEquals("getNodeName must return #document",expResult, result);
54     }
55
56     /**
57      * Test of createElement method, of class org.netbeans.modules.xml.xdm.nodes.Document.
58      */

59     public void testCreateElement() {
60         
61         String JavaDoc tagName = "newElement";
62         org.w3c.dom.Element JavaDoc result = doc.createElement(tagName);
63         assertEquals(tagName, result.getTagName());
64     }
65
66     /**
67      * Test of createAttribute method, of class org.netbeans.modules.xml.xdm.nodes.Document.
68      */

69     public void testCreateAttribute() {
70         
71         String JavaDoc name = "attrName";
72         org.w3c.dom.Attr JavaDoc result = doc.createAttribute(name);
73         assertEquals(name, result.getName());
74     }
75
76     /**
77      * Test of createElementNS method, of class org.netbeans.modules.xml.xdm.nodes.Document.
78      */

79     public void testCreateElementNS() {
80         
81         String JavaDoc namespaceURI = "";
82         String JavaDoc qualifiedName = "xs:element";
83         org.w3c.dom.Element JavaDoc result = doc.createElementNS(namespaceURI, qualifiedName);
84         assertEquals("element", result.getLocalName());
85         assertEquals("xs", result.getPrefix());
86     }
87
88     /**
89      * Test of createAttributeNS method, of class org.netbeans.modules.xml.xdm.nodes.Document.
90      */

91     public void testCreateAttributeNS() {
92         
93         String JavaDoc namespaceURI = "";
94         String JavaDoc qualifiedName = "xs:attribute";
95         org.w3c.dom.Attr JavaDoc result = doc.createAttributeNS(namespaceURI, qualifiedName);
96         assertEquals("attribute", result.getLocalName());
97         assertEquals("xs", result.getPrefix());
98     }
99
100     /**
101      * Test of getDocumentElement method, of class org.netbeans.modules.xml.xdm.nodes.Document.
102      */

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     /**
112      * Test of getXmlVersion method, of class org.netbeans.modules.xml.xdm.nodes.Document.
113      */

114     public void testGetXmlVersion() {
115         
116         String JavaDoc expResult = "1.0";
117         String JavaDoc result = doc.getXmlVersion();
118         assertEquals(expResult, result);
119     }
120
121     /**
122      * Test of getXmlEncoding method, of class org.netbeans.modules.xml.xdm.nodes.Document.
123      */

124     public void testGetXmlEncoding() {
125         
126         String JavaDoc expResult = "UTF-8";
127         String JavaDoc result = doc.getXmlEncoding();
128         assertEquals(expResult, result);
129     }
130
131     /**
132      * Test of getXmlStandalone method, of class org.netbeans.modules.xml.xdm.nodes.Document.
133      */

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