use of org.apache.stanbol.ontologymanager.sources.owlapi.RootOntologySource in project stanbol by apache.
the class TestStorage method storedOntologyOutlivesScope.
/**
* If an ontology is removed from a scope, or the scope itself is torn down, this should not result in the
* deletion of that ontology in general.
*/
@Test
public void storedOntologyOutlivesScope() throws Exception {
String ephemeralScopeId = "CaducousScope";
OntologyInputSource<OWLOntology> ois = new RootOntologySource(org.semanticweb.owlapi.model.IRI.create(getClass().getResource("/ontologies/nonexistentcharacters.owl")));
OWLOntologyID ontologyId = ois.getRootOntology().getOntologyID();
Scope scope = onManager.createOntologyScope(ephemeralScopeId);
// Initially, the ontology is not there
assertFalse(ontologyProvider.hasOntology(ontologyId));
// Once added, the ontology is there
scope.getCustomSpace().addOntology(ois);
assertTrue(ontologyProvider.hasOntology(ontologyId));
// Once removed from the scope, the ontology is still there
scope.getCustomSpace().removeOntology(ontologyId);
assertTrue(ontologyProvider.hasOntology(ontologyId));
// Once the scope is killed, the ontology is still there
// TODO find a more appropriate method to kill scopes?
scope.tearDown();
assertTrue(ontologyProvider.hasOntology(ontologyId));
}
Aggregations