KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > filter > plugins > DateFilterTest


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.mail.filter.plugins;
19
20 import java.util.Date JavaDoc;
21 import java.util.GregorianCalendar JavaDoc;
22
23 import org.columba.mail.filter.MailFilterCriteria;
24 import org.columba.mail.filter.MailFilterFactory;
25 import org.columba.mail.folder.MailboxTstFactory;
26
27 /**
28  * @author fdietz
29  *
30  */

31 public class DateFilterTest extends AbstractFilterTst {
32
33     /**
34      * @param arg0
35      */

36     public DateFilterTest(String JavaDoc arg0) {
37         super(arg0);
38
39     }
40
41     /**
42      * @param arg0
43      */

44     public DateFilterTest(MailboxTstFactory factory, String JavaDoc arg0) {
45         super(factory, arg0);
46
47     }
48
49     /**
50      * Test date before.
51      *
52      * @throws Exception
53      */

54     public void testBefore() throws Exception JavaDoc {
55         // add message to folder
56
Object JavaDoc uid = addMessage();
57
58         GregorianCalendar JavaDoc c = new GregorianCalendar JavaDoc();
59         c.set(2004, 5, 10);
60         Date JavaDoc date = c.getTime();
61         getSourceFolder().setAttribute(uid, "columba.date", date);
62
63         // create filter configuration
64
MailFilterCriteria criteria = MailFilterFactory
65                 .createDateBefore("Jan 17, 2005");
66
67         // create filter
68
DateFilter filter = new DateFilter();
69
70         // init configuration
71
filter.setUp(criteria);
72
73         // execute filter
74
filter.process(getSourceFolder(), uid);
75
76         // TODO: fix testcase
77
//assertEquals("filter result", true, result);
78
}
79
80     /**
81      * Test date after.
82      *
83      * @throws Exception
84      */

85     public void testAfter() throws Exception JavaDoc {
86         // add message to folder
87
Object JavaDoc uid = addMessage();
88
89         GregorianCalendar JavaDoc c = new GregorianCalendar JavaDoc();
90         c.set(2004, 5, 10);
91         Date JavaDoc date = c.getTime();
92         getSourceFolder().setAttribute(uid, "columba.date", date);
93
94         // create filter configuration
95
MailFilterCriteria criteria = MailFilterFactory
96                 .createDateAfter("Jan 17, 2005");
97
98         // create filter
99
DateFilter filter = new DateFilter();
100
101         // init configuration
102
filter.setUp(criteria);
103
104         // execute filter
105
boolean result = filter.process(getSourceFolder(), uid);
106         assertEquals("filter result", false, result);
107     }
108 }
Popular Tags