}
public void testValidateDocument(String fileName, List<MessageId> errors, List<MessageId> warnings,
List<MessageId> fatalErrors, EPUBVersion version, boolean verbose)
{
ValidationReport testReport = new ValidationReport(fileName, String.format(Messages.get("single_file"), "opf",
version.toString()));
GenericResourceProvider resourceProvider;
if (fileName.startsWith("http://") || fileName.startsWith("https://"))
{
resourceProvider = new URLResourceProvider(fileName);
} else
{
String basepath = null;
if (version == EPUBVersion.VERSION_2)
{
basepath = "/20/single/opf/";
} else if (version == EPUBVersion.VERSION_3)
{
basepath = "/30/single/opf/";
}
URL fileURL = this.getClass().getResource(basepath + fileName);
String filePath = fileURL != null ? fileURL.getPath() : basepath + fileName;
resourceProvider = new FileResourceProvider(filePath);
}
OPFChecker opfChecker = null;
if (version == EPUBVersion.VERSION_2)
{
opfChecker = new OPFChecker("test_single_opf", resourceProvider, testReport);
} else if (version == EPUBVersion.VERSION_3)
{
opfChecker = new OPFChecker30("test_single_opf", resourceProvider, testReport);
}
assert opfChecker != null;
opfChecker.validate();
if (verbose)
{
outWriter.println(testReport);
}
assertEquals("The error results do not match", errors, testReport.getErrorIds());
assertEquals("The warning results do not match", warnings, testReport.getWarningIds());
assertEquals("The fatal error results do not match", fatalErrors, testReport.getFatalErrorIds());
}