protected static void invokeMethodConsideringTimeout(ITestNGMethod tm, ConstructorOrMethod method, Object targetInstance, Object[] params, ITestResult testResult) throws Throwable { if (MethodHelper.calculateTimeOut(tm) <= 0) { MethodInvocationHelper.invokeMethod(method.getMethod(), targetInstance, params); } else { MethodInvocationHelper.invokeWithTimeout(tm, targetInstance, params, testResult); if (!testResult.isSuccess()) { // A time out happened Throwable ex = testResult.getThrowable(); testResult.setStatus(ITestResult.FAILURE); testResult.setThrowable(ex.getCause() == null ? ex : ex.getCause()); throw testResult.getThrowable(); } } }
private static void invokeWithTimeoutWithNoExecutor(ITestNGMethod tm, Object instance, Object[] parameterValues, ITestResult testResult, IHookable hookable) { InvokeMethodRunnable imr = new InvokeMethodRunnable(tm, instance, parameterValues, hookable, testResult); long startTime = System.currentTimeMillis(); long realTimeOut = MethodHelper.calculateTimeOut(tm); try { imr.run(); if (System.currentTimeMillis() <= startTime + realTimeOut) { testResult.setStatus(ITestResult.SUCCESS); } else { ThreadTimeoutException exception = new ThreadTimeoutException("Method " + tm.getQualifiedName() + "()" + " didn't finish within the time-out " + realTimeOut); testResult.setThrowable(exception); testResult.setStatus(ITestResult.FAILURE); } } catch (Exception ex) { testResult.setThrowable(ex.getCause()); testResult.setStatus(ITestResult.FAILURE); } }
protected static void invokeMethodConsideringTimeout( ITestNGMethod tm, ConstructorOrMethod method, Object targetInstance, Object[] params, ITestResult testResult) throws Throwable { if (MethodHelper.calculateTimeOut(tm) <= 0) { MethodInvocationHelper.invokeMethod(method.getMethod(), targetInstance, params); } else { MethodInvocationHelper.invokeWithTimeout(tm, targetInstance, params, testResult); if (!testResult.isSuccess()) { // A time out happened Throwable ex = testResult.getThrowable(); testResult.setStatus(ITestResult.FAILURE); testResult.setThrowable(ex.getCause() == null ? ex : ex.getCause()); throw testResult.getThrowable(); } } }
private static void invokeWithTimeoutWithNoExecutor( ITestNGMethod tm, Object instance, Object[] parameterValues, ITestResult testResult, IHookable hookable) { InvokeMethodRunnable imr = new InvokeMethodRunnable(tm, instance, parameterValues, hookable, testResult); long startTime = System.currentTimeMillis(); long realTimeOut = MethodHelper.calculateTimeOut(tm); try { imr.run(); if (System.currentTimeMillis() <= startTime + realTimeOut) { testResult.setStatus(ITestResult.SUCCESS); } else { ThreadTimeoutException exception = new ThreadTimeoutException( "Method " + tm.getQualifiedName() + "()" + " didn't finish within the time-out " + realTimeOut); testResult.setThrowable(exception); testResult.setStatus(ITestResult.FAILURE); } } catch (Exception ex) { testResult.setThrowable(ex.getCause()); testResult.setStatus(ITestResult.FAILURE); } }
IFutureResult future = exec.submitRunnable(imr); exec.shutdown(); long realTimeOut = MethodHelper.calculateTimeOut(tm); boolean finished = exec.awaitTermination(realTimeOut);
IFutureResult future = exec.submitRunnable(imr); exec.shutdown(); long realTimeOut = MethodHelper.calculateTimeOut(tm); boolean finished = exec.awaitTermination(realTimeOut);
if (MethodHelper.calculateTimeOut(tm) <= 0) { if (hookableInstance != null) { MethodInvocationHelper.invokeHookable(instance,
: m_configuration.getHookable(); if (MethodHelper.calculateTimeOut(arguments.getTestMethod()) <= 0) { if (hookableInstance != null) { MethodInvocationHelper.invokeHookable(