KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > folder > AllTests


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.folder;
19
20 import java.lang.reflect.InvocationTargetException JavaDoc;
21 import java.lang.reflect.Method JavaDoc;
22
23 import junit.framework.Test;
24 import junit.framework.TestCase;
25 import junit.framework.TestSuite;
26
27 /**
28  * @author fdietz
29  *
30  */

31 public class AllTests {
32
33     private static String JavaDoc[] list = { "AddMessageFolderTest",
34             "ExpungeFolderTest", "CopyMessageFolderTest",
35             "GetMessageSourceStreamTest", "GetMimePartSourceStreamTest",
36             "GetHeaderFieldsTest","AttributeTest"};
37
38     /**
39      * Add all testcases to the passed testsuite, using a the folder type as
40      * created in the factory.
41      *
42      * @param suite
43      * test suite
44      * @param factory
45      * factory which creates the folder instances
46      */

47     private static void setup(TestSuite suite, MailboxTstFactory factory) {
48         try {
49             for (int j = 0; j < list.length; j++) {
50                 Class JavaDoc clazz = Class.forName("org.columba.mail.folder."
51                         + list[j]);
52
53                 Method JavaDoc[] methods = clazz.getDeclaredMethods();
54                 for (int i = 0; i < methods.length; i++) {
55                     if (methods[i].getName().startsWith("test")) {
56
57                         suite.addTest((TestCase) clazz.getConstructor(
58                                 new Class JavaDoc[] { MailboxTstFactory.class,
59                                         String JavaDoc.class}).newInstance(
60                                 new Object JavaDoc[] { factory, methods[i].getName()}));
61                     }
62                 }
63             }
64         } catch (SecurityException JavaDoc e) {
65
66             e.printStackTrace();
67         } catch (IllegalArgumentException JavaDoc e) {
68
69             e.printStackTrace();
70         } catch (ClassNotFoundException JavaDoc e) {
71
72             e.printStackTrace();
73         } catch (InstantiationException JavaDoc e) {
74
75             e.printStackTrace();
76         } catch (IllegalAccessException JavaDoc e) {
77
78             e.printStackTrace();
79         } catch (InvocationTargetException JavaDoc e) {
80
81             e.printStackTrace();
82         } catch (NoSuchMethodException JavaDoc e) {
83
84             e.printStackTrace();
85         }
86     }
87
88     public static Test suite() {
89         TestSuite suite = new TestSuite("Test for org.columba.mail.folder");
90
91         setup(suite, new MHFolderFactory());
92         setup(suite, new MBOXFolderTstFactory());
93         setup(suite, new TempFolderFactory());
94         // disabled IMAP folder tests as they require connection
95
// to remote IMAP server
96
//setup(suite, new IMAPTstFactory());
97

98         return suite;
99     }
100 }
Popular Tags