1 8 9 package com.sleepycat.je.junit; 10 11 import java.lang.reflect.Method ; 12 13 import junit.framework.TestCase; 14 15 18 public class JUnitMethodThread extends JUnitThread { 19 20 private TestCase testCase; 21 private Method method; 22 private Object param; 23 24 public JUnitMethodThread(String threadName, String methodName, 25 TestCase testCase) 26 throws NoSuchMethodException { 27 28 this(threadName, methodName, testCase, null); 29 } 30 31 public JUnitMethodThread(String threadName, String methodName, 32 TestCase testCase, Object param) 33 throws NoSuchMethodException { 34 35 super(threadName); 36 this.testCase = testCase; 37 this.param = param; 38 method = testCase.getClass().getMethod(methodName, new Class [0]); 39 } 40 41 public void testBody() 42 throws Exception { 43 44 if (param != null) { 45 method.invoke(testCase, new Object [] { param }); 46 } else { 47 method.invoke(testCase, new Object [0]); 48 } 49 } 50 } 51 | Popular Tags |