1 package org.columba.mail.folder; 19 20 import java.lang.reflect.InvocationTargetException ; 21 import java.lang.reflect.Method ; 22 23 import junit.framework.Test; 24 import junit.framework.TestCase; 25 import junit.framework.TestSuite; 26 27 31 public class AllTests { 32 33 private static String [] list = { "AddMessageFolderTest", 34 "ExpungeFolderTest", "CopyMessageFolderTest", 35 "GetMessageSourceStreamTest", "GetMimePartSourceStreamTest", 36 "GetHeaderFieldsTest","AttributeTest"}; 37 38 47 private static void setup(TestSuite suite, MailboxTstFactory factory) { 48 try { 49 for (int j = 0; j < list.length; j++) { 50 Class clazz = Class.forName("org.columba.mail.folder." 51 + list[j]); 52 53 Method [] 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 [] { MailboxTstFactory.class, 59 String .class}).newInstance( 60 new Object [] { factory, methods[i].getName()})); 61 } 62 } 63 } 64 } catch (SecurityException e) { 65 66 e.printStackTrace(); 67 } catch (IllegalArgumentException e) { 68 69 e.printStackTrace(); 70 } catch (ClassNotFoundException e) { 71 72 e.printStackTrace(); 73 } catch (InstantiationException e) { 74 75 e.printStackTrace(); 76 } catch (IllegalAccessException e) { 77 78 e.printStackTrace(); 79 } catch (InvocationTargetException e) { 80 81 e.printStackTrace(); 82 } catch (NoSuchMethodException 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 98 return suite; 99 } 100 } | Popular Tags |