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


001:        package org.columba.mail.parser;
002:
003:        import java.util.Enumeration;
004:        import java.util.List;
005:        import java.util.Vector;
006:
007:        import javax.swing.ImageIcon;
008:        import javax.swing.tree.TreeNode;
009:
010:        import junit.framework.TestCase;
011:
012:        import org.columba.addressbook.facade.ContactItem;
013:        import org.columba.addressbook.facade.GroupItem;
014:        import org.columba.addressbook.facade.HeaderItem;
015:        import org.columba.addressbook.facade.IContactFacade;
016:        import org.columba.addressbook.facade.IContactItem;
017:        import org.columba.addressbook.facade.IFolder;
018:        import org.columba.addressbook.facade.IFolderFacade;
019:        import org.columba.addressbook.facade.IGroupItem;
020:        import org.columba.addressbook.facade.IHeaderItem;
021:        import org.columba.api.exception.StoreException;
022:        import org.columba.core.facade.ServiceFacadeRegistry;
023:
024:        public class ListBuilderTest extends TestCase {
025:
026:            private IContactItem contact1;
027:
028:            private IContactItem contact2;
029:
030:            private IGroupItem group1;
031:
032:            private IGroupItem group2;
033:
034:            @Override
035:            protected void setUp() throws Exception {
036:
037:                IContactFacade contactFacade = new MyContactFacade();
038:                IFolderFacade folderFacade = new MyFolderFacade();
039:
040:                ServiceFacadeRegistry.getInstance().register(
041:                        IContactFacade.class, contactFacade);
042:                ServiceFacadeRegistry.getInstance().register(
043:                        IFolderFacade.class, folderFacade);
044:
045:                contact1 = new ContactItem("0", "name1", "firstname1",
046:                        "lastname1", "name1@mail.org");
047:                contact2 = new ContactItem("1", "name2", "firstname2",
048:                        "lastname2", "name2@mail.org");
049:
050:                // create group containing first contact
051:                group1 = new GroupItem("0", "groupname1", "description1");
052:                group1.addContact(contact1);
053:
054:                // create group with two contacts
055:                group2 = new GroupItem("1", "groupname2", "description2");
056:                group2.addContact(contact1);
057:                group2.addContact(contact2);
058:            }
059:
060:            /**
061:             * Test if contact display names are resolved correctly in email address
062:             */
063:            public void testCreateFlatListWithNamesOnly() {
064:                List<String> l = new Vector<String>();
065:                l.add("name1");
066:                l.add("name2");
067:
068:                List<String> result = ListBuilder.createFlatList(l);
069:                assertEquals("name1@mail.org", result.get(0));
070:                assertEquals("name2@mail.org", result.get(1));
071:
072:            }
073:
074:            /**
075:             * Now, mix in real email address
076:             */
077:            public void testCreateFlatListWithEmailAddressMixedIn() {
078:                List<String> l = new Vector<String>();
079:                l.add("name1");
080:                l.add("name2@mail.org");
081:
082:                List<String> result = ListBuilder.createFlatList(l);
083:                assertEquals("name1@mail.org", result.get(0));
084:                assertEquals("name2@mail.org", result.get(1));
085:
086:            }
087:
088:            /**
089:             * Test if groups are resolved correctly 
090:             *
091:             */
092:            public void testCreateFlatListWithGroups() {
093:                List<String> l = new Vector<String>();
094:                l.add("groupname1");
095:                l.add("name2@mail.org");
096:
097:                List<String> result = ListBuilder.createFlatList(l);
098:                // first group contains first contact item
099:                assertEquals("name1@mail.org", result.get(0));
100:                assertEquals("name2@mail.org", result.get(1));
101:
102:            }
103:
104:            /**
105:             * Again, but with a group containing two contact items
106:             *
107:             */
108:            public void testCreateFlatListWithGroups2() {
109:                List<String> l = new Vector<String>();
110:                l.add("groupname2");
111:                l.add("name2@mail.org");
112:
113:                List<String> result = ListBuilder.createFlatList(l);
114:                // first group contains first contact item
115:                assertEquals("name1@mail.org", result.get(0));
116:                assertEquals("name2@mail.org", result.get(1));
117:                assertEquals("name2@mail.org", result.get(2));
118:
119:            }
120:
121:            /*
122:             * Test method for
123:             * 'org.columba.mail.parser.ListBuilder.createStringListFromItemList(List<IHeaderItem>)'
124:             */
125:            public void testCreateStringListFromItemList() {
126:
127:                List<IHeaderItem> l = new Vector<IHeaderItem>();
128:                IHeaderItem item1 = new HeaderItem(true);
129:                item1.setName("name1");
130:                l.add(item1);
131:                IHeaderItem item2 = new HeaderItem(true);
132:                item2.setName("name2");
133:                l.add(item2);
134:
135:                List<String> result = ListBuilder
136:                        .createStringListFromItemList(l);
137:                assertEquals("name1", result.get(0));
138:                assertEquals("name2", result.get(1));
139:            }
140:
141:            // mock folder class, only returns folder id
142:            class Folder implements  IFolder {
143:                Folder() {
144:
145:                }
146:
147:                public ImageIcon getIcon() {
148:                    return null;
149:                }
150:
151:                public String getId() {
152:                    return "101";
153:                }
154:
155:                public String getName() {
156:                    return null;
157:                }
158:
159:                public TreeNode getChildAt(int childIndex) {
160:                    return null;
161:                }
162:
163:                public int getChildCount() {
164:                    return 0;
165:                }
166:
167:                public TreeNode getParent() {
168:                    return null;
169:                }
170:
171:                public int getIndex(TreeNode node) {
172:                    return 0;
173:                }
174:
175:                public boolean getAllowsChildren() {
176:                    return false;
177:                }
178:
179:                public boolean isLeaf() {
180:                    return false;
181:                }
182:
183:                public Enumeration children() {
184:                    return null;
185:                }
186:            }
187:
188:            // mock object folder facade, only returns folder list
189:            class MyFolderFacade implements  IFolderFacade {
190:                MyFolderFacade() {
191:
192:                }
193:
194:                public IFolder getFolder(String uid) {
195:                    return null;
196:                }
197:
198:                public IFolder getCollectedAddresses() {
199:                    return null;
200:                }
201:
202:                public IFolder getLocalAddressbook() {
203:                    return null;
204:                }
205:
206:                public IFolder getFolderByName(String name) {
207:                    return null;
208:                }
209:
210:                public List<IFolder> getAllFolders() {
211:                    List<IFolder> list = new Vector<IFolder>();
212:                    IFolder f = new Folder();
213:
214:                    list.add(f);
215:
216:                    return list;
217:                }
218:
219:                public IFolder getRootFolder() {
220:                    return null;
221:                }
222:            }
223:
224:            // mock objects contact facade, only returns getContactItem() and
225:            // getAllGroups()
226:            class MyContactFacade implements  IContactFacade {
227:                MyContactFacade() {
228:
229:                }
230:
231:                public void addContact(String id, IContactItem contactItem)
232:                        throws StoreException, IllegalArgumentException {
233:
234:                }
235:
236:                public void addContacts(String id, IContactItem[] contactItem)
237:                        throws StoreException, IllegalArgumentException {
238:                }
239:
240:                public void addContact(IContactItem contactItem)
241:                        throws StoreException, IllegalArgumentException {
242:
243:                }
244:
245:                public void addContacts(IContactItem[] contactItems)
246:                        throws StoreException, IllegalArgumentException {
247:
248:                }
249:
250:                public IContactItem getContactItem(String folderId,
251:                        String contactId) throws StoreException,
252:                        IllegalArgumentException {
253:                    if (contactId.equals("0"))
254:                        return contact1;
255:                    else if (contactId.equals("1"))
256:                        return contact2;
257:                    return null;
258:                }
259:
260:                public List<IHeaderItem> getAllHeaderItems(String folderId,
261:                        boolean flattenGroupItems) throws StoreException,
262:                        IllegalArgumentException {
263:                    return null;
264:                }
265:
266:                public List<IContactItem> getAllContacts(String folderId)
267:                        throws StoreException, IllegalArgumentException {
268:                    return null;
269:                }
270:
271:                public List<IGroupItem> getAllGroups(String folderId)
272:                        throws StoreException, IllegalArgumentException {
273:                    List<IGroupItem> list = new Vector<IGroupItem>();
274:                    list.add(group1);
275:                    list.add(group2);
276:                    return list;
277:                }
278:
279:                public String findByEmailAddress(String folderId,
280:                        String emailAddress) throws StoreException,
281:                        IllegalArgumentException {
282:
283:                    return null;
284:                }
285:
286:                public String findByName(String folderId, String name)
287:                        throws StoreException, IllegalArgumentException {
288:                    if (name.equals("name1"))
289:                        return "0";
290:                    else if (name.equals("name2"))
291:                        return "1";
292:
293:                    return null;
294:                }
295:            }
296:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.