001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.gui.composer.command;
019:
020: import java.lang.reflect.InvocationTargetException;
021: import java.lang.reflect.Method;
022:
023: import junit.framework.Test;
024: import junit.framework.TestCase;
025: import junit.framework.TestSuite;
026:
027: import org.columba.mail.folder.MBOXFolderTstFactory;
028: import org.columba.mail.folder.MHFolderFactory;
029: import org.columba.mail.folder.MailboxTstFactory;
030: import org.columba.mail.folder.TempFolderFactory;
031:
032: /**
033: * @author fdietz
034: *
035: */
036: public class AllTests {
037:
038: private static String[] list = { "ReplyCommandTest",
039: "ReplyToAllCommandTest", "ReplyToMailingListCommandTest",
040: "ForwardCommandTest", "ForwardInlineCommandTest" };
041:
042: /**
043: * Add all testcases to the passed testsuite, using a the folder type as
044: * created in the factory.
045: *
046: * @param suite
047: * test suite
048: * @param factory
049: * factory which creates the folder instances
050: */
051: private static void setup(TestSuite suite, MailboxTstFactory factory) {
052: try {
053: for (int j = 0; j < list.length; j++) {
054: Class clazz = Class
055: .forName("org.columba.mail.gui.composer.command."
056: + list[j]);
057:
058: Method[] methods = clazz.getDeclaredMethods();
059: for (int i = 0; i < methods.length; i++) {
060: if (methods[i].getName().startsWith("test")) {
061:
062: suite.addTest((TestCase) clazz.getConstructor(
063: new Class[] { MailboxTstFactory.class,
064: String.class }).newInstance(
065: new Object[] { factory,
066: methods[i].getName() }));
067: }
068: }
069: }
070: } catch (SecurityException e) {
071:
072: e.printStackTrace();
073: } catch (IllegalArgumentException e) {
074:
075: e.printStackTrace();
076: } catch (ClassNotFoundException e) {
077:
078: e.printStackTrace();
079: } catch (InstantiationException e) {
080:
081: e.printStackTrace();
082: } catch (IllegalAccessException e) {
083:
084: e.printStackTrace();
085: } catch (InvocationTargetException e) {
086:
087: e.printStackTrace();
088: } catch (NoSuchMethodException e) {
089:
090: e.printStackTrace();
091: }
092: }
093:
094: public static Test suite() {
095: TestSuite suite = new TestSuite(
096: "Test for org.columba.mail.gui.composer.command");
097:
098: setup(suite, new MHFolderFactory());
099: setup(suite, new MBOXFolderTstFactory());
100: setup(suite, new TempFolderFactory());
101: // disabled IMAP folder tests as they require connection
102: // to remote IMAP server
103: // setup(suite, new IMAPTstFactory());
104:
105: return suite;
106: }
107: }
|