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());
}
}
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());
}
}
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));
}
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);
}
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());
}
}
Aggregations