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


001:        /*
002:         * Created on 2003-okt-30
003:         */
004:        package org.columba.mail.filter;
005:
006:        import junit.framework.TestCase;
007:
008:        import org.columba.core.filter.Filter;
009:        import org.columba.core.filter.FilterList;
010:        import org.columba.core.filter.IFilter;
011:        import org.columba.core.xml.XmlElement;
012:
013:        /**
014:         * Tests for the <code>FilterList</code> class.
015:         * 
016:         * @author redsolo
017:         */
018:        public class FilterListTest extends TestCase {
019:            /**
020:             * Test to add filters to the list. The method should be able to handle
021:             * nulls as well.
022:             */
023:            public void testAdd() {
024:                FilterList filterList = new FilterList(new XmlElement());
025:                filterList.add(createNamedFilter("ONE"));
026:                assertEquals("Wrong number of filters in the list.", 1,
027:                        filterList.count());
028:                filterList.add(null);
029:                assertEquals("Wrong number of filters in the list.", 1,
030:                        filterList.count());
031:                filterList.add(createNamedFilter("ONE"));
032:                assertEquals("Wrong number of filters in the list.", 2,
033:                        filterList.count());
034:            }
035:
036:            /**
037:             * Test to remove filters from the list.
038:             */
039:            public void testRemoveFilter() {
040:                FilterList filterList = new FilterList(new XmlElement());
041:                IFilter filterTwo = createNamedFilter("TWO");
042:                filterList.add(createNamedFilter("ONE"));
043:                filterList.add(filterTwo);
044:                filterList.add(createNamedFilter("THREE"));
045:                assertEquals("Wrong number of filters in the list.", 3,
046:                        filterList.count());
047:
048:                filterList.remove(filterTwo);
049:                assertEquals("Wrong number of filters in the list.", 2,
050:                        filterList.count());
051:                filterList.remove(null);
052:                assertEquals("Wrong number of filters in the list.", 2,
053:                        filterList.count());
054:            }
055:
056:            /**
057:             * Test the count() method.
058:             *  
059:             */
060:            public void testCount() {
061:                FilterList filterList = new FilterList(new XmlElement());
062:                assertEquals("Expected an empty filter list", 0, filterList
063:                        .count());
064:                filterList.add(FilterList.createDefaultFilter());
065:                assertEquals("Expected a filter list with one filter", 1,
066:                        filterList.count());
067:                filterList.remove(0);
068:                assertEquals("Expected an empty filter list", 0, filterList
069:                        .count());
070:            }
071:
072:            /**
073:             * Test for Filter#get(int)
074:             */
075:            public void testGetint() {
076:                FilterList filterList = new FilterList(new XmlElement());
077:                IFilter filterOne = createNamedFilter("ONE");
078:                IFilter filterTwo = createNamedFilter("TWO");
079:                IFilter filterThree = createNamedFilter("THREE");
080:                filterList.add(filterOne);
081:                filterList.add(filterTwo);
082:                filterList.add(filterThree);
083:                assertEquals("The get(int) method returned the wrong filter.",
084:                        filterOne, filterList.get(0));
085:                assertEquals("The get(int) method returned the wrong filter.",
086:                        filterTwo, filterList.get(1));
087:                assertEquals("The get(int) method returned the wrong filter.",
088:                        filterThree, filterList.get(2));
089:            }
090:
091:            /**
092:             * Test for insert(Filter, int) method.
093:             */
094:            public void testInsert() {
095:                FilterList filterList = new FilterList(new XmlElement());
096:                IFilter filterOne = createNamedFilter("ONE");
097:                IFilter filterTwo = createNamedFilter("TWO");
098:                IFilter filterThree = createNamedFilter("THREE");
099:                filterList.add(filterOne);
100:                filterList.add(filterTwo);
101:                filterList.add(filterThree);
102:                assertEquals("The get(int) method returned the wrong filter.",
103:                        filterOne, filterList.get(0));
104:                assertEquals("The get(int) method returned the wrong filter.",
105:                        filterTwo, filterList.get(1));
106:
107:                IFilter filterFour = createNamedFilter("FOUR");
108:                filterList.insert(filterFour, 1);
109:                assertEquals("The get(int) method returned the wrong filter.",
110:                        filterOne, filterList.get(0));
111:                assertEquals("The get(int) method returned the wrong filter.",
112:                        filterFour, filterList.get(1));
113:                assertEquals("The get(int) method returned the wrong filter.",
114:                        filterTwo, filterList.get(2));
115:            }
116:
117:            /**
118:             * Test to move up a filter in the list.
119:             */
120:            public void testMoveUp() {
121:                FilterList filterList = new FilterList(new XmlElement());
122:                IFilter filterOne = createNamedFilter("ONE");
123:                IFilter filterTwo = createNamedFilter("TWO");
124:                IFilter filterThree = createNamedFilter("THREE");
125:                filterList.add(filterOne);
126:                filterList.add(filterTwo);
127:                filterList.add(filterThree);
128:                assertEquals("The get(int) method returned the wrong filter.",
129:                        filterOne, filterList.get(0));
130:                assertEquals("The get(int) method returned the wrong filter.",
131:                        filterThree, filterList.get(2));
132:                filterList.moveUp(filterThree);
133:                assertEquals("The get(int) method returned the wrong filter.",
134:                        filterThree, filterList.get(1));
135:                filterList.moveUp(filterThree);
136:                assertEquals("The get(int) method returned the wrong filter.",
137:                        filterThree, filterList.get(0));
138:                assertEquals("The get(int) method returned the wrong filter.",
139:                        filterOne, filterList.get(1));
140:                filterList.moveUp(filterThree);
141:                assertEquals("The get(int) method returned the wrong filter.",
142:                        filterThree, filterList.get(0));
143:            }
144:
145:            /**
146:             * Test to move down a filter in the list.
147:             */
148:            public void testMoveDown() {
149:                FilterList filterList = new FilterList(new XmlElement());
150:                IFilter filterOne = createNamedFilter("ONE");
151:                IFilter filterTwo = createNamedFilter("TWO");
152:                IFilter filterThree = createNamedFilter("THREE");
153:                filterList.add(filterOne);
154:                filterList.add(filterTwo);
155:                filterList.add(filterThree);
156:                assertEquals("The get(int) method returned the wrong filter.",
157:                        filterOne, filterList.get(0));
158:                assertEquals("The get(int) method returned the wrong filter.",
159:                        filterThree, filterList.get(2));
160:                filterList.moveDown(filterOne);
161:                assertEquals("The get(int) method returned the wrong filter.",
162:                        filterOne, filterList.get(1));
163:                filterList.moveDown(filterOne);
164:                assertEquals("The get(int) method returned the wrong filter.",
165:                        filterOne, filterList.get(2));
166:                assertEquals("The get(int) method returned the wrong filter.",
167:                        filterThree, filterList.get(1));
168:                filterList.moveDown(filterOne);
169:                assertEquals("The get(int) method returned the wrong filter.",
170:                        filterOne, filterList.get(2));
171:            }
172:
173:            /**
174:             * Test for indexOf() method.
175:             */
176:            public void testIndexOf() {
177:                FilterList filterList = new FilterList(new XmlElement());
178:                IFilter filterOne = createNamedFilter("ONE");
179:                IFilter filterTwo = createNamedFilter("TWO");
180:                IFilter filterThree = createNamedFilter("THREE");
181:                filterList.add(filterOne);
182:                filterList.add(filterTwo);
183:                filterList.add(filterThree);
184:
185:                assertEquals(
186:                        "The indexof() method did not return the right index",
187:                        -1, filterList.indexOf(null));
188:                assertEquals(
189:                        "The indexof() method did not return the right index",
190:                        0, filterList.indexOf(filterOne));
191:                assertEquals(
192:                        "The indexof() method did not return the right index",
193:                        1, filterList.indexOf(filterTwo));
194:                assertEquals(
195:                        "The indexof() method did not return the right index",
196:                        2, filterList.indexOf(filterThree));
197:                assertEquals(
198:                        "The indexof() method did not return the right index",
199:                        -1, filterList.indexOf(createNamedFilter("NONE")));
200:            }
201:
202:            /**
203:             * Returns an empty filter with a specified name.
204:             * 
205:             * @param name
206:             *            the name of the filter.
207:             * @return a <code>Filter</code> with the specified name.
208:             */
209:            private IFilter createNamedFilter(String name) {
210:                IFilter filter = FilterList.createDefaultFilter();
211:                filter.setName(name);
212:
213:                return filter;
214:            }
215:
216:            /**
217:             * Asserts that the filters are the same.
218:             * 
219:             * @param msg
220:             *            the message to output if the assertion fails.
221:             * @param expected
222:             *            the expected filter.
223:             * @param actual
224:             *            the actual filter.
225:             */
226:            private void assertEquals(String msg, Filter expected, Filter actual) {
227:                assertEquals(msg, expected.getName(), actual.getName());
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.