KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > junit > internal > LocationCaller


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.junit.internal;
8
9
10 import java.lang.reflect.InvocationTargetException JavaDoc;
11 import java.lang.reflect.Method JavaDoc;
12
13 import com.inversoft.junit.WebTestCase;
14
15
16 /**
17  * This class does the reflective calling of the test methods
18  * at the location side of the tests.
19  *
20  * @author Brian Pontarelli
21  * @since 2.0
22  * @version 2.0
23  */

24 public class LocationCaller {
25
26     /**
27      * Calls the test method on the WebTestCase given
28      *
29      * @param testCase The WebTestCase instance to call the test on
30      * @throws Throwable If the test failed or the method throw an Exception
31      */

32     public void callTestMethod(WebTestCase testCase) throws Throwable JavaDoc {
33
34         try {
35             Class JavaDoc klass = testCase.getClass();
36             Method JavaDoc method = klass.getMethod(testCase.getName(), new Class JavaDoc[0]);
37
38             method.invoke(testCase, new Object JavaDoc[0]);
39         } catch (InvocationTargetException JavaDoc ite) {
40             ite.fillInStackTrace();
41             throw ite.getTargetException();
42         } catch (IllegalAccessException JavaDoc e) {
43             e.fillInStackTrace();
44             throw e;
45         } catch (NoSuchMethodException JavaDoc nsme) {
46             nsme.fillInStackTrace();
47             throw nsme;
48         }
49     }
50 }
Popular Tags