}
static ValidationReport savedReport;
public void testValidateDocument(String fileName, List<MessageId> errors, List<MessageId> warnings, List<MessageId> fatalErrors, String resultFile, boolean verbose)
{
DocumentValidator epubCheck;
outWriter.printf("Starting testValidateDocument('%s')\n", fileName);
ValidationReport testReport;
if (fileName.startsWith("http://") || fileName.startsWith("https://"))
{
GenericResourceProvider resourceProvider = new URLResourceProvider(fileName);
try
{
testReport = savedReport = new ValidationReport(fileName);
epubCheck = new EpubCheck(
resourceProvider.getInputStream(null), testReport, fileName);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
else
{
File testFile;
try
{
URL url = this.getClass().getResource(basepath + fileName);
URI uri = url.toURI();
testFile = new File(uri);
}
catch (URISyntaxException e)
{
throw new IllegalStateException("Cannot find test file", e);
}
if (testFile.isDirectory())
{
Archive epub = new Archive(testFile.getPath());
testReport = savedReport = new ValidationReport(epub.getEpubName());
epub.createArchive();
epubCheck = new EpubCheck(epub.getEpubFile(), testReport);
}
else
{
testReport = savedReport = new ValidationReport(fileName);
epubCheck = new EpubCheck(new File(testFile.getPath()), testReport);
}
}
epubCheck.validate();
if (verbose)
{
outWriter.println(testReport);
}