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.folder;
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: /**
028: * @author fdietz
029: *
030: */
031: public class AllTests {
032:
033: private static String[] list = { "AddMessageFolderTest",
034: "ExpungeFolderTest", "CopyMessageFolderTest",
035: "GetMessageSourceStreamTest",
036: "GetMimePartSourceStreamTest", "GetHeaderFieldsTest",
037: "AttributeTest" };
038:
039: /**
040: * Add all testcases to the passed testsuite, using a the folder type as
041: * created in the factory.
042: *
043: * @param suite
044: * test suite
045: * @param factory
046: * factory which creates the folder instances
047: */
048: private static void setup(TestSuite suite, MailboxTstFactory factory) {
049: try {
050: for (int j = 0; j < list.length; j++) {
051: Class clazz = Class.forName("org.columba.mail.folder."
052: + list[j]);
053:
054: Method[] methods = clazz.getDeclaredMethods();
055: for (int i = 0; i < methods.length; i++) {
056: if (methods[i].getName().startsWith("test")) {
057:
058: suite.addTest((TestCase) clazz.getConstructor(
059: new Class[] { MailboxTstFactory.class,
060: String.class }).newInstance(
061: new Object[] { factory,
062: methods[i].getName() }));
063: }
064: }
065: }
066: } catch (SecurityException e) {
067:
068: e.printStackTrace();
069: } catch (IllegalArgumentException e) {
070:
071: e.printStackTrace();
072: } catch (ClassNotFoundException e) {
073:
074: e.printStackTrace();
075: } catch (InstantiationException e) {
076:
077: e.printStackTrace();
078: } catch (IllegalAccessException e) {
079:
080: e.printStackTrace();
081: } catch (InvocationTargetException e) {
082:
083: e.printStackTrace();
084: } catch (NoSuchMethodException e) {
085:
086: e.printStackTrace();
087: }
088: }
089:
090: public static Test suite() {
091: TestSuite suite = new TestSuite(
092: "Test for org.columba.mail.folder");
093:
094: setup(suite, new MHFolderFactory());
095: setup(suite, new MBOXFolderTstFactory());
096: setup(suite, new TempFolderFactory());
097: // disabled IMAP folder tests as they require connection
098: // to remote IMAP server
099: //setup(suite, new IMAPTstFactory());
100:
101: return suite;
102: }
103: }
|