private static AntUnitSuite getJUnit3AntSuite(Class testCaseClass)
throws InitializationError {
try {
Method suiteMethod = testCaseClass.getMethod("suite", new Class[0]);
if (!Modifier.isStatic(suiteMethod.getModifiers())) {
throw new InitializationError("suite method must be static");
}
Object suite = suiteMethod.invoke(null, new Object[0]);
if (suite == null) {
throw new InitializationError("suite method can not return null");
}
if (!(suite instanceof AntUnitSuite)) {
throw new InitializationError("suite method must return an AntUnitSuite");
}
return (AntUnitSuite) suite;
} catch (NoSuchMethodException e) {
throw new InitializationError(new Throwable[] { e });
} catch (IllegalAccessException e) {
throw new InitializationError(new Throwable[] { e });
} catch (InvocationTargetException e) {
throw new InitializationError(new Throwable[] { e });
}
}