KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > composer > command > 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.gui.composer.command;
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 import org.columba.mail.folder.MBOXFolderTstFactory;
28 import org.columba.mail.folder.MHFolderFactory;
29 import org.columba.mail.folder.MailboxTstFactory;
30 import org.columba.mail.folder.TempFolderFactory;
31
32 /**
33  * @author fdietz
34  *
35  */

36 public class AllTests {
37
38     private static String JavaDoc[] list = { "ReplyCommandTest",
39             "ReplyToAllCommandTest", "ReplyToMailingListCommandTest",
40             "ForwardCommandTest", "ForwardInlineCommandTest" };
41
42     /**
43      * Add all testcases to the passed testsuite, using a the folder type as
44      * created in the factory.
45      *
46      * @param suite
47      * test suite
48      * @param factory
49      * factory which creates the folder instances
50      */

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

106         return suite;
107     }
108 }
Popular Tags