public static void assertRDFFilesIsomorphic(File expected, File actual, RDFFormat format) throws Exception {
final RDFFormat expectedFormat;
final RDFFormat actualFormat;
if (format == null) {
final RDFParserRegistry registry = RDFParserRegistry.getInstance();
expectedFormat =
registry.getFileFormatForFileName(expected.getName()).orElse(null);
actualFormat =
registry.getFileFormatForFileName(actual.getName()).orElse(null);
assertNotNull("Can't guess the expected file format", expectedFormat);
assertNotNull("Can't guess the actual file format", actualFormat);
} else {
expectedFormat = format;
actualFormat = format;
}
final Model expectedModel;
final Model actualModel;
try (final InputStream expectedStream = new FileInputStream(expected);
final InputStream actualStream = new FileInputStream(actual)) {
expectedModel = Rio.parse(expectedStream, "base://", expectedFormat);
actualModel = Rio.parse(actualStream, "base://", actualFormat);
}
assertTrue("RDF files are not isomorphic",
Models.isomorphic(expectedModel, actualModel));
}