Object testInstance = testMethodExecutor.getInstance();
String testClass = testInstance.getClass().getName();
String testMethod = testMethodExecutor.getMethod().getName();
TestResult result = null;
try
{
ObjectName objectName = new ObjectName(JMXTestRunnerMBean.OBJECT_NAME);
JMXTestRunnerMBean testRunner = getMBeanProxy(objectName, JMXTestRunnerMBean.class);
ExecutionType type = (ExecutionType)properties.get(ExecutionType.class);
if (type == ExecutionType.EMBEDDED)
{
byte[] resultBytes = testRunner.runTestMethodSerialized(testClass, testMethod, properties);
ByteArrayInputStream resultStream = new ByteArrayInputStream(resultBytes);
ObjectInputStream ois = new ObjectInputStream(resultStream);
result = (TestResult)ois.readObject();
}
else
{
result = testRunner.runTestMethod(testClass, testMethod, properties);
}
}
catch (final Throwable e)
{
result = new TestResult(Status.FAILED);
result.setThrowable(e);
}
finally
{
result.setEnd(System.currentTimeMillis());
}
return result;
}