// Minimum offset required is 2 because of an owl:versionInfo triple in-between.
String location = "/owl/versioned.owl";
log.info("Testing lookahead for location {}", location);
IRI incubatedVersion = IRI
.create("http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/owl/src/test/resources/owl/versioned.owl");
OWLOntologyID expectedOntId = new OWLOntologyID(ontologyIri, incubatedVersion);
// Low triple limit: guessing should fail.
InputStream content = getClass().getResourceAsStream(location);
OWLOntologyID id = OWLUtils.guessOntologyID(content, parser, RDF_XML, 10);
assertTrue(id.isAnonymous());
// Reasonable triple limit with low offset: guessing should return the unversioned ID.
content = getClass().getResourceAsStream(location);
id = OWLUtils.guessOntologyID(content, parser, RDF_XML, 256, 1);
assertNotNull(id);
assertFalse(id.isAnonymous());
assertEquals(new OWLOntologyID(ontologyIri), id);
// Reasonable triple limit with auto offset: guessing should succeed.
content = getClass().getResourceAsStream(location);
id = OWLUtils.guessOntologyID(content, parser, RDF_XML, 256);
assertNotNull(id);
assertFalse(id.isAnonymous());
assertEquals(expectedOntId, id);
// No triple limit: guessing should succeed.
content = getClass().getResourceAsStream(location);
id = OWLUtils.guessOntologyID(content, parser, RDF_XML);
assertNotNull(id);
assertFalse(id.isAnonymous());
assertEquals(expectedOntId, id);
}