1 17 18 package org.sape.carbon.core.test; 19 20 import java.lang.reflect.InvocationTargetException ; 21 import java.lang.reflect.Method ; 22 import java.lang.reflect.Modifier ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.Set ; 26 27 import org.sape.carbon.core.bootstrap.test.BootStrapperTest; 28 import org.sape.carbon.core.util.reflection.ClassFinder; 29 30 import junit.framework.Test; 31 import junit.framework.TestCase; 32 import junit.framework.TestSuite; 33 34 49 public class CoreTest extends TestCase { 50 51 private static Set excludedTests; 52 53 static { 54 excludedTests = new HashSet (); 55 excludedTests.add(BootStrapperTest.class.getName()); 56 excludedTests.add(CoreTest.class.getName()); 57 58 62 } 63 64 public CoreTest(String name) { 65 super(name); 66 } 67 68 public static Test suite() { 69 TestSuite suite = new TestSuite(); 70 71 suite.addTest(BootStrapperTest.suite()); 72 73 ClassFinder classFinder = new ClassFinder(TestCase.class, "org.sape.carbon"); 74 Set testClasses = classFinder.getClasses(); 75 76 ClassFinder perfClassFinder = new ClassFinder(TestCase.class,"PerformanceTest"); 77 Set performanceClasses = perfClassFinder.getClasses(); 78 79 boolean result = testClasses.removeAll(performanceClasses); 80 81 Iterator testClassIterator = testClasses.iterator(); 82 while(testClassIterator.hasNext()) { 83 String testClassName = (String ) testClassIterator.next(); 84 85 if (!excludedTests.contains(testClassName)) { 86 try { 87 Class testClass = Class.forName(testClassName); 88 Method suiteMethod = testClass.getMethod("suite", null); 89 if (Modifier.isStatic(suiteMethod.getModifiers())) { 90 suite.addTest((Test) suiteMethod.invoke(null, null)); 91 } 92 93 } catch(SecurityException e) { 96 } catch(IllegalArgumentException e) { 97 } catch(ClassNotFoundException e) { 98 } catch(NoSuchMethodException e) { 99 } catch(IllegalAccessException e) { 100 } catch(InvocationTargetException e) { 101 } 102 } 103 } 104 105 return suite; 106 } 107 108 } 109 | Popular Tags |