Object[] parameterValues, ITestResult testResult)
throws InterruptedException, ThreadExecutionException {
IExecutor exec = ThreadUtil.createExecutor(1, tm.getMethod().getName());
InvokeMethodRunnable imr = new InvokeMethodRunnable(tm, instance, parameterValues);
IFutureResult future = exec.submitRunnable(imr);
exec.shutdown();
long realTimeOut = MethodHelper.calculateTimeOut(tm);
boolean finished = exec.awaitTermination(realTimeOut);
if (!finished) {
exec.stopNow();
ThreadTimeoutException exception = new ThreadTimeoutException("Method "
+ tm.getClass().getName() + "." + tm.getMethodName() + "()"
+ " didn't finish within the time-out " + realTimeOut);
exception.setStackTrace(exec.getStackTraces()[0]);
testResult.setThrowable(exception);
testResult.setStatus(ITestResult.FAILURE);
} else {
Utils.log("Invoker " + Thread.currentThread().hashCode(), 3, "Method " + tm.getMethod()
+ " completed within the time-out " + tm.getTimeOut());
// We don't need the result from the future but invoking get() on it
// will trigger the exception that was thrown, if any
future.get();
// done.await();
testResult.setStatus(ITestResult.SUCCESS); // if no exception till here
// than SUCCESS
}