Search in sources :

Example 11 with RootOntologySource

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));
}
Also used : Scope(org.apache.stanbol.ontologymanager.servicesapi.scope.Scope) RootOntologySource(org.apache.stanbol.ontologymanager.sources.owlapi.RootOntologySource) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) Test(org.junit.Test)

Aggregations

RootOntologySource (org.apache.stanbol.ontologymanager.sources.owlapi.RootOntologySource)11 UnmodifiableOntologyCollectorException (org.apache.stanbol.ontologymanager.servicesapi.collector.UnmodifiableOntologyCollectorException)7 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)7 OWLOntologyID (org.semanticweb.owlapi.model.OWLOntologyID)5 IOException (java.io.IOException)4 Consumes (javax.ws.rs.Consumes)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)4 POST (javax.ws.rs.POST)3 DuplicateIDException (org.apache.stanbol.ontologymanager.servicesapi.collector.DuplicateIDException)3 Scope (org.apache.stanbol.ontologymanager.servicesapi.scope.Scope)3 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 IRI (org.apache.clerezza.commons.rdf.IRI)2 LibrarySource (org.apache.stanbol.ontologymanager.registry.io.LibrarySource)2 IrremovableOntologyException (org.apache.stanbol.ontologymanager.servicesapi.collector.IrremovableOntologyException)2 MissingOntologyException (org.apache.stanbol.ontologymanager.servicesapi.collector.MissingOntologyException)2 OntologyCollectorModificationException (org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollectorModificationException)2 OntologyLoadingException (org.apache.stanbol.ontologymanager.servicesapi.ontology.OntologyLoadingException)2