Search in sources :

Example 6 with OntologySpace

use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.

the class TestClerezzaSpaces method testCustomLock.

@Test
public void testCustomLock() throws Exception {
    OntologySpace space = factory.createCustomOntologySpace(scopeId, inMemorySrc);
    space.setUp();
    try {
        space.addOntology(minorSrc);
        fail("Modification was permitted on locked ontology space.");
    } catch (UnmodifiableOntologyCollectorException e) {
        assertSame(space, e.getOntologyCollector());
    }
}
Also used : UnmodifiableOntologyCollectorException(org.apache.stanbol.ontologymanager.servicesapi.collector.UnmodifiableOntologyCollectorException) OntologySpace(org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace) Test(org.junit.Test)

Example 7 with OntologySpace

use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.

the class TestClerezzaSpaces method testCoreLock.

@Test
public void testCoreLock() throws Exception {
    OntologySpace space = factory.createCoreOntologySpace(scopeId, inMemorySrc);
    space.setUp();
    try {
        space.addOntology(minorSrc);
        fail("Modification was permitted on locked ontology space.");
    } catch (UnmodifiableOntologyCollectorException e) {
        assertSame(space, e.getOntologyCollector());
    }
}
Also used : UnmodifiableOntologyCollectorException(org.apache.stanbol.ontologymanager.servicesapi.collector.UnmodifiableOntologyCollectorException) OntologySpace(org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace) Test(org.junit.Test)

Example 8 with OntologySpace

use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.

the class TestClerezzaSpaces method testCreateSpace.

@Test
public void testCreateSpace() throws Exception {
    OntologySpace space = factory.createCustomOntologySpace(scopeId, dropSrc);
    OWLOntologyID logicalId = null;
    Object o = dropSrc.getRootOntology();
    if (o instanceof Graph)
        logicalId = OWLUtils.extractOntologyID((Graph) o);
    else if (o instanceof OWLOntology)
        logicalId = OWLUtils.extractOntologyID((OWLOntology) o);
    assertNotNull(logicalId);
    assertTrue(space.hasOntology(logicalId));
}
Also used : Graph(org.apache.clerezza.commons.rdf.Graph) OntologySpace(org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace) OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) Test(org.junit.Test)

Example 9 with OntologySpace

use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.

the class TestClerezzaSpaces method testIdentifiers.

/**
     * Checks whether attempting to create ontology spaces with invalid identifiers or namespaces results in
     * the appropriate exceptions being thrown.
     * 
     * @throws Exception
     *             if an unexpected error occurs.
     */
@Test
public void testIdentifiers() throws Exception {
    OntologySpace shouldBeNull = null, shouldBeNotNull = null;
    // Null identifier (invalid).
    try {
        shouldBeNull = factory.createOntologySpace(null, SpaceType.CORE);
        fail("Expected IllegalArgumentException not thrown despite null scope identifier.");
    } catch (IllegalArgumentException ex) {
    }
    assertNull(shouldBeNull);
    // More than one slash in identifier (invalid).
    try {
        shouldBeNull = factory.createOntologySpace("Sc0/p3", SpaceType.CORE);
        fail("Expected IllegalArgumentException not thrown despite null scope identifier.");
    } catch (IllegalArgumentException ex) {
    }
    assertNull(shouldBeNull);
    /* Now test namespaces. */
    // Null namespace (invalid).
    factory.setDefaultNamespace(null);
    try {
        shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE);
        fail("Expected IllegalArgumentException not thrown despite null OntoNet namespace.");
    } catch (IllegalArgumentException ex) {
    }
    assertNull(shouldBeNull);
    // Namespace with query (invalid).
    factory.setDefaultNamespace(IRI.create("http://stanbol.apache.org/ontology/?query=true"));
    try {
        shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE);
        fail("Expected IllegalArgumentException not thrown despite query in OntoNet namespace.");
    } catch (IllegalArgumentException ex) {
    }
    assertNull(shouldBeNull);
    // Namespace with fragment (invalid).
    factory.setDefaultNamespace(IRI.create("http://stanbol.apache.org/ontology#fragment"));
    try {
        shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE);
        fail("Expected IllegalArgumentException not thrown despite fragment in OntoNet namespace.");
    } catch (IllegalArgumentException ex) {
    }
    assertNull(shouldBeNull);
    // Namespace ending with hash (invalid).
    factory.setDefaultNamespace(IRI.create("http://stanbol.apache.org/ontology#"));
    try {
        shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE);
        fail("Expected IllegalArgumentException not thrown despite fragment in OntoNet namespace.");
    } catch (IllegalArgumentException ex) {
    }
    assertNull(shouldBeNull);
    // Namespace ending with neither (valid, should automatically add slash).
    factory.setDefaultNamespace(IRI.create("http://stanbol.apache.org/ontology"));
    shouldBeNotNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE);
    assertNotNull(shouldBeNotNull);
    assertTrue(shouldBeNotNull.getDefaultNamespace().toString().endsWith("/"));
    shouldBeNotNull = null;
    // Namespace ending with slash (valid).
    factory.setDefaultNamespace(IRI.create("http://stanbol.apache.org/ontology/"));
    shouldBeNotNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE);
    assertNotNull(shouldBeNotNull);
}
Also used : OntologySpace(org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace) Test(org.junit.Test)

Example 10 with OntologySpace

use of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace in project stanbol by apache.

the class TestOntologySpaces method testCoreLock.

@Test
public void testCoreLock() throws Exception {
    OntologySpace space = factory.createCoreOntologySpace("testCoreLock", inMemorySrc);
    space.setUp();
    try {
        space.addOntology(minorSrc);
        fail("Modification was permitted on locked ontology space.");
    } catch (UnmodifiableOntologyCollectorException e) {
        assertSame(space, e.getOntologyCollector());
    }
}
Also used : UnmodifiableOntologyCollectorException(org.apache.stanbol.ontologymanager.servicesapi.collector.UnmodifiableOntologyCollectorException) OntologySpace(org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace) Test(org.junit.Test)

Aggregations

OntologySpace (org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace)29 Test (org.junit.Test)13 IRI (org.semanticweb.owlapi.model.IRI)9 UnmodifiableOntologyCollectorException (org.apache.stanbol.ontologymanager.servicesapi.collector.UnmodifiableOntologyCollectorException)8 OWLOntologyID (org.semanticweb.owlapi.model.OWLOntologyID)8 Path (javax.ws.rs.Path)7 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)7 GET (javax.ws.rs.GET)6 Produces (javax.ws.rs.Produces)6 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)6 Scope (org.apache.stanbol.ontologymanager.servicesapi.scope.Scope)4 OWLOntologyCreationException (org.semanticweb.owlapi.model.OWLOntologyCreationException)4 IOException (java.io.IOException)3 IRI (org.apache.clerezza.commons.rdf.IRI)3 ImmutableGraph (org.apache.clerezza.commons.rdf.ImmutableGraph)3 DuplicateIDException (org.apache.stanbol.ontologymanager.servicesapi.collector.DuplicateIDException)3 MissingOntologyException (org.apache.stanbol.ontologymanager.servicesapi.collector.MissingOntologyException)3 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)3 InputStream (java.io.InputStream)2 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)2