if (!this.skip)
{
final File expectedOutputArchive = new File(this.expectedOutputArchive);
if (!expectedOutputArchive.exists() || !expectedOutputArchive.isFile())
{
throw new MojoExecutionException("The path specifying the expectedOutputArchive '" +
this.expectedOutputArchive + "' must be a file");
}
try
{
this.getLog().info("-----------------------------------------------------------------------------");
this.getLog().info(" A n d r o M D A C a r t r i d g e T e s t S u i t e ");
this.getLog().info("-----------------------------------------------------------------------------");
// - add the cartridge test dependencies (any dependencies of the cartridge test plugin)
this.addCartridgeTestDependencies();
// - first run AndroMDA with the test configuration
final AndroMDAMojo andromdaMojo = new AndroMDAMojo();
andromdaMojo.setConfigurationUri(this.configurationUri);
andromdaMojo.setProject(this.project);
andromdaMojo.setSettings(this.settings);
andromdaMojo.setPropertyFiles(this.propertyFiles);
andromdaMojo.execute();
// - unpack the expected output archive
this.unpack(
expectedOutputArchive,
new File(this.expectedDirectory));
final CartridgeTest cartridgeTest = CartridgeTest.instance();
cartridgeTest.setActualOutputPath(this.actualDirectory);
cartridgeTest.setExpectedOutputPath(this.expectedDirectory);
cartridgeTest.setBinarySuffixes(this.binaryOutputSuffixes);
final CartridgeTestFormatter formatter = new CartridgeTestFormatter();
// - set the report location
final File report = new File(this.reportDirectory, this.project.getArtifactId() + ".txt");
formatter.setReportFile(report);
final TestResult result = new TestResult();
result.addListener(formatter);
final Test suite = CartridgeTest.suite();
formatter.startTestSuite(this.project.getName());
suite.run(result);
this.getLog().info("");
this.getLog().info("Results:");
this.getLog().info(formatter.endTestSuite(suite));
cartridgeTest.shutdown();
if (result.failureCount() > 0 || result.errorCount() > 0)
{
throw new MojoExecutionException("Test are some test failures");
}
}
catch (final Throwable throwable)
{
if (throwable instanceof MojoExecutionException)
{
throw (MojoExecutionException)throwable;
}
throw new MojoExecutionException("An error occured while testing cartridge '" +
this.project.getArtifactId() + "'",
ExceptionUtils.getRootCause(throwable));
}
}
else