Source Code Cross Referenced for AccountItemTest.java in  » Mail-Clients » columba-1.4 » org » columba » mail » config » 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.mail.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 2003-11-02
003:         */
004:        package org.columba.mail.config;
005:
006:        import junit.framework.TestCase;
007:
008:        import org.columba.core.xml.XmlElement;
009:
010:        /**
011:         * Test cases for the <code>AccountItem</code> class.
012:         *
013:         * @author karlpeder
014:         */
015:        public class AccountItemTest extends TestCase {
016:            /*
017:             * Test for int hashCode().
018:             */
019:            public void testHashCode() {
020:                // first account item
021:                XmlElement xml = new XmlElement("account");
022:                xml.addAttribute("name", "my account");
023:                xml.addAttribute("uid", "0");
024:
025:                XmlElement child = xml.addSubElement("identity");
026:                child.addAttribute("name", "John Doe");
027:                child.addAttribute("attach_signature", "false");
028:                child = xml.addSubElement("popserver");
029:                child.addAttribute("port", "25");
030:                child.addAttribute("login_method", "USER");
031:                child = xml.addSubElement("specialfolders");
032:                child.addAttribute("inbox", "101");
033:                child.addAttribute("sent", "104");
034:
035:                AccountItem item = new AccountItem(xml);
036:
037:                // second account item
038:                XmlElement xml2 = new XmlElement("account");
039:                xml2.addAttribute("uid", "0");
040:                xml2.addAttribute("name", "my account");
041:
042:                XmlElement child2 = xml2.addSubElement("identity");
043:                child2.addAttribute("attach_signature", "false");
044:                child2.addAttribute("name", "John Doe");
045:                child2 = xml2.addSubElement("popserver");
046:                child2.addAttribute("login_method", "USER");
047:                child2.addAttribute("port", "25");
048:                child2 = xml2.addSubElement("specialfolders");
049:                child2.addAttribute("sent", "104");
050:                child2.addAttribute("inbox", "101");
051:
052:                AccountItem item2 = new AccountItem(xml2);
053:
054:                // third item, a bit different from the first
055:                XmlElement xml3 = new XmlElement("account");
056:                xml3.addAttribute("name", "my account");
057:                xml3.addAttribute("uid", "0");
058:
059:                XmlElement child3 = xml3.addSubElement("identity");
060:                child3.addAttribute("name", "Kalle Kamel");
061:                child3.addAttribute("attach_signature", "false");
062:                child3 = xml3.addSubElement("popserver");
063:                child3.addAttribute("port", "25");
064:                child3.addAttribute("login_method", "USER");
065:                child3 = xml3.addSubElement("specialfolders");
066:                child3.addAttribute("inbox", "101");
067:                child3.addAttribute("sent", "104");
068:
069:                AccountItem item3 = new AccountItem(xml3);
070:
071:                // should have the same hashcodes...
072:                assertTrue("The hashcodes of item and item2 are not the same",
073:                        item.hashCode() == item2.hashCode());
074:
075:                // expect a different hashcode from a newly created item...
076:                assertFalse(
077:                        "The hashcodes of item and a new object are the same",
078:                        item.hashCode() == (new AccountItem(new XmlElement()))
079:                                .hashCode());
080:
081:                // expect a different hashcode for item and item3
082:                assertFalse("The hashcodes of item and item3 are the same",
083:                        item.hashCode() == item3.hashCode());
084:            }
085:
086:            /*
087:             * Test for boolean equals(Object)
088:             */
089:            public void testEqualsObject() {
090:                // first account item
091:                XmlElement xml = new XmlElement("account");
092:                xml.addAttribute("name", "my account");
093:                xml.addAttribute("uid", "0");
094:
095:                XmlElement child = xml.addSubElement("identity");
096:                child.addAttribute("name", "John Doe");
097:                child.addAttribute("attach_signature", "false");
098:                child = xml.addSubElement("popserver");
099:                child.addAttribute("port", "25");
100:                child.addAttribute("login_method", "USER");
101:                child = xml.addSubElement("specialfolders");
102:                child.addAttribute("inbox", "101");
103:                child.addAttribute("sent", "104");
104:
105:                AccountItem item = new AccountItem(xml);
106:
107:                // second account item
108:                XmlElement xml2 = new XmlElement("account");
109:                xml2.addAttribute("uid", "0");
110:                xml2.addAttribute("name", "my account");
111:
112:                XmlElement child2 = xml2.addSubElement("identity");
113:                child2.addAttribute("attach_signature", "false");
114:                child2.addAttribute("name", "John Doe");
115:                child2 = xml2.addSubElement("popserver");
116:                child2.addAttribute("login_method", "USER");
117:                child2.addAttribute("port", "25");
118:                child2 = xml2.addSubElement("specialfolders");
119:                child2.addAttribute("sent", "104");
120:                child2.addAttribute("inbox", "101");
121:
122:                AccountItem item2 = new AccountItem(xml2);
123:
124:                // third item, a bit different from the first
125:                XmlElement xml3 = new XmlElement("account");
126:                xml3.addAttribute("name", "my account");
127:                xml3.addAttribute("uid", "0");
128:
129:                XmlElement child3 = xml3.addSubElement("identity");
130:                child3.addAttribute("name", "Kalle Kamel");
131:                child3.addAttribute("attach_signature", "false");
132:                child3 = xml3.addSubElement("popserver");
133:                child3.addAttribute("port", "25");
134:                child3.addAttribute("login_method", "USER");
135:                child3 = xml3.addSubElement("specialfolders");
136:                child3.addAttribute("inbox", "101");
137:                child3.addAttribute("sent", "104");
138:
139:                AccountItem item3 = new AccountItem(xml3);
140:
141:                // test self equality...
142:                assertTrue("Self equality failed for item", item.equals(item));
143:                assertTrue("Self equality failed for item2", item2
144:                        .equals(item2));
145:
146:                // item and item2 should be equal...
147:                assertTrue("item and item2 are not equal", item.equals(item2));
148:                assertTrue("item2 and item are not equal", item2.equals(item));
149:
150:                // item and item2 should be two different objects
151:                assertNotSame("item and item2 refers to the same object", item,
152:                        item2);
153:
154:                // item should not be equal to a newly created item or null
155:                assertFalse("item is equal to a newly created AccountItem",
156:                        item.equals(new AccountItem(new XmlElement())));
157:                assertFalse("item is equal to null", item.equals(null));
158:
159:                // item and item3 should not be equal
160:                assertFalse("item and item3 are equal", item.equals(item3));
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.