Source Code Cross Referenced for XmlElementTest.java in  » Mail-Clients » columba-1.4 » org » columba » core » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » columba 1.4 » org.columba.core.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 2003-okt-30
003:         */
004:        package org.columba.core.xml;
005:
006:        import junit.framework.TestCase;
007:
008:        /**
009:         * Tests for the <code>XmlElement</code> class.
010:         *
011:         * @author Erik Mattsson
012:         */
013:        public class XmlElementTest extends TestCase {
014:            /*
015:             * Test for boolean equals(Object)
016:             */
017:            public void testEquals() {
018:                XmlElement xml1 = new XmlElement();
019:                XmlElement xml2 = new XmlElement();
020:                xml1.setName("ONE");
021:                xml2.setName("ONE");
022:                xml1.setData("DATA");
023:                xml2.setData("DATA");
024:                xml1.addAttribute("name", "value");
025:                xml2.addAttribute("name", "value");
026:
027:                XmlElement child1 = new XmlElement("child1");
028:                XmlElement sibling1 = new XmlElement("sibling1");
029:                XmlElement child2 = new XmlElement("child2");
030:                XmlElement sibling2 = new XmlElement("sibling2");
031:
032:                child1.addElement((XmlElement) child2.clone());
033:                child1.addElement((XmlElement) sibling2.clone());
034:
035:                xml1.addElement((XmlElement) child1.clone());
036:                xml1.addElement((XmlElement) sibling1.clone());
037:                xml2.addElement((XmlElement) child1.clone());
038:                xml2.addElement((XmlElement) sibling1.clone());
039:
040:                assertTrue("The XML elements are not equal", xml1.equals(xml2));
041:                assertTrue("The XML elements are not equal", xml2.equals(xml1));
042:                assertTrue("The XML elements are not equal", xml1.equals(xml1));
043:                assertTrue("The XML elements are not equal", xml2.equals(xml2));
044:
045:                assertFalse("The XML elements are equal to null ", xml1
046:                        .equals(null));
047:                assertFalse("The XML elements are equal to null ", xml2
048:                        .equals(null));
049:            }
050:
051:            /*
052:             * Test for boolean equals(Object)
053:             */
054:            public void testEquals2() {
055:                XmlElement xml1 = new XmlElement();
056:                XmlElement xml2 = new XmlElement();
057:                xml1.setName("ONE");
058:                xml2.setName("ONE");
059:                xml1.setData("DATA");
060:                xml2.setData("DATA");
061:                xml1.addAttribute("name", "value");
062:                assertTrue("The XML elements are equal", !xml1.equals(xml2));
063:                assertTrue("The XML elements are equal", !xml2.equals(xml1));
064:            }
065:
066:            /*
067:             * Test for boolean not equals(Object)
068:             */
069:            public void testNotEqualsObject() {
070:                XmlElement xml1 = new XmlElement();
071:                XmlElement xml2 = new XmlElement();
072:                xml1.setName("ONE");
073:                xml2.setName("ONE");
074:                xml1.addElement(new XmlElement("child1"));
075:                assertTrue("The XML elements are equal", !xml1.equals(xml2));
076:                assertTrue("The XML elements are equal", !xml2.equals(xml1));
077:            }
078:
079:            /*
080:             * Test for hashCode()
081:             */
082:            public void testHashcode() {
083:                XmlElement xml1 = new XmlElement();
084:                XmlElement xml2 = new XmlElement();
085:                xml1.setName("ONE");
086:                xml2.setName("ONE");
087:                xml1.addElement(new XmlElement("child1"));
088:                xml2.addElement(new XmlElement("child1"));
089:                assertEquals("The hashcode are not equal", xml2.hashCode(),
090:                        xml1.hashCode());
091:            }
092:
093:            /*
094:             * Test for clone()
095:             */
096:            public void testClone() {
097:                XmlElement xml1 = new XmlElement("a Name");
098:                XmlElement xml2 = (XmlElement) xml1.clone();
099:                assertEquals("The parent and the cloned object are not equal",
100:                        xml1, xml2);
101:                assertNotSame("The parent and the cloned object are the same",
102:                        xml1, xml2);
103:                assertNotSame(
104:                        "The parent and the cloned Attributes objects are the same object.",
105:                        xml1.getAttributes(), xml2.getAttributes());
106:                assertNotSame(
107:                        "The parent and the cloned Sub Element objects are the same object.",
108:                        xml1.getElements(), xml2.getElements());
109:
110:                xml1 = new XmlElement("a Name", "data");
111:                xml2 = (XmlElement) xml1.clone();
112:                assertEquals("The parent and the cloned object are not equal",
113:                        xml1, xml2);
114:                assertNotSame("The parent and the cloned object are the same",
115:                        xml1, xml2);
116:                assertNotSame(
117:                        "The parent and the cloned Attributes objects are the same object.",
118:                        xml1.getAttributes(), xml2.getAttributes());
119:                assertNotSame(
120:                        "The parent and the cloned Sub Element objects are the same object.",
121:                        xml1.getElements(), xml2.getElements());
122:
123:                xml1 = new XmlElement();
124:                xml1.setName("a NAME");
125:                xml1.addAttribute("key", "values");
126:                xml1.addAttribute("key2", "other values");
127:                xml1.addSubElement("child");
128:                xml1.addSubElement(new XmlElement("child2"));
129:                xml2 = (XmlElement) xml1.clone();
130:                assertEquals("The parent and the cloned object are not equal",
131:                        xml1, xml2);
132:                assertNotSame("The parent and the cloned object are the same",
133:                        xml1, xml2);
134:                assertNotSame(
135:                        "The parent and the cloned Attributes objects are the same object.",
136:                        xml1.getAttributes(), xml2.getAttributes());
137:                assertNotSame(
138:                        "The parent and the cloned Sub Element objects are the same object.",
139:                        xml1.getElements(), xml2.getElements());
140:                assertEquals("The Name is not the same", "a NAME", xml2
141:                        .getName());
142:                assertEquals(
143:                        "The value for Attributes key='key' is not the expected",
144:                        "values", xml2.getAttribute("key"));
145:                assertEquals(
146:                        "The value for Attributes key='key2' is not the expected",
147:                        "other values", xml2.getAttribute("key2"));
148:                assertEquals("The first childs name is not the expected",
149:                        "child", xml2.getElement(0).getName());
150:                assertEquals("The second childs name is not the expected",
151:                        "child2", xml2.getElement(1).getName());
152:                assertEquals(
153:                        "The parent and cloned object hashCode() methods return different values.",
154:                        xml1.hashCode(), xml2.hashCode());
155:            }
156:
157:            /*
158:             * Test for XmlElement(String,String)
159:             */
160:            public void testConstructorStrStr() {
161:                XmlElement xml = new XmlElement("a Name", "a Data");
162:                xml.addAttribute("key", "values");
163:                xml.addAttribute("key2", "other values");
164:                xml.addSubElement("child");
165:                xml.addSubElement(new XmlElement("child2"));
166:
167:                assertEquals("The Name isnt correct", "a Name", xml.getName());
168:                assertEquals("The Data isnt correct", "a Data", xml.getData());
169:                assertEquals("The attribute 'key' isnt correct", "values", xml
170:                        .getAttribute("key"));
171:                assertEquals("The attribute 'key' isnt correct",
172:                        "other values", xml.getAttribute("key2"));
173:                assertEquals("The child element isnt correct", "child", xml
174:                        .getElement(0).getName());
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.