currentResult = new TestResult(name.substring(12));
description = name;
checkPoint(null);
Testlet t = null;
try
{
Class k = Class.forName(name);
int mods = k.getModifiers();
if (Modifier.isAbstract(mods))
{
description = NOT_A_TEST_DESCRIPTION;
return;
}
Object o = k.newInstance();
if (! (o instanceof Testlet))
{
description = NOT_A_TEST_DESCRIPTION;
return;
}
if (o instanceof VisualTestlet)
{
if (! interactive)
{
description = NOT_A_TEST_DESCRIPTION;
return;
}
}
else
{
if (interactive)
{
description = NOT_A_TEST_DESCRIPTION;
return;
}
}
t = (Testlet) o;
}
catch (Throwable ex)
{
description = FAIL_TO_LOAD_DESCRIPTION;
// Maybe the file was marked not-a-test, check that before we report
// it as an error
try
{
File f = new File(name.replace('.', File.separatorChar) + ".java");
BufferedReader r = new BufferedReader(new FileReader(f));
String firstLine = r.readLine();
// Since some people mistakenly put not-a-test not as the first line
// we have to check through the file.
while (firstLine != null)
{
if (firstLine.indexOf("not-a-test") != -1)
{
description = NOT_A_TEST_DESCRIPTION;
return;
}
firstLine = r.readLine();
}
}
catch(FileNotFoundException fnfe)
{
}
catch (IOException ioe)
{
}
String r = getStackTraceString(ex, " ");
currentResult.addException(ex, "failed loading class ", r);
debug(ex);
if (ex instanceof InstantiationException
|| ex instanceof IllegalAccessException)
debug("Hint: is the code we just loaded a public non-abstract "
+ "class with a public nullary constructor???");
if (!verbose)
System.out.println ("FAIL: " + stripPrefix(name)
+ "\n exception when loading:");
else
{
System.out.println ("TEST: "+stripPrefix(name));
System.out.println(" FAIL: exception when loading");
}
if (exceptions)
System.out.println(getStackTraceString(ex, " "));
if (verbose)
System.out.println("TEST FAILED: exception when loading "
+ stripPrefix(name));
if (report != null)
report.addTestResult(currentResult);
return;
}
// If the harness started okay, now we run the test.
if (t != null)
{
try
{
if (verbose)
System.out.println("TEST: " + stripPrefix(name));
t.test(this);
removeSecurityManager();
}
catch (Throwable ex)
{