Object testInstance = testMethodExecutor.getInstance();
String testClass = testInstance.getClass().getName();
String testMethod = testMethodExecutor.getMethod().getName();
TestResult result = null;
NotificationListener listener = null;
try
{
JMXTestRunnerMBean testRunner = getMBeanProxy(JMXTestRunnerMBean.OBJECT_NAME, JMXTestRunnerMBean.class);
listener = registerNotificationListener(JMXTestRunnerMBean.OBJECT_NAME, testRunner, testInstance);
if (executionType == ExecutionType.EMBEDDED)
{
InputStream resultStream = testRunner.runTestMethodEmbedded(testClass, testMethod, props);
result = Utils.deserialize(resultStream, TestResult.class);
}
else if (executionType == ExecutionType.REMOTE)
{
result = testRunner.runTestMethod(testClass, testMethod, props);
}
}
catch (final Throwable e)
{
result = new TestResult(Status.FAILED);
result.setThrowable(e);
}
finally
{
result.setEnd(System.currentTimeMillis());
unregisterNotificationListener(JMXTestRunnerMBean.OBJECT_NAME, listener);
}
return result;
}