/* First test space identifiers. */
// Null identifier (invalid).
try {
shouldBeNull = factory.createOntologySpace(null, SpaceType.CORE, new BlankOntologySource());
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, new BlankOntologySource());
fail("Expected IllegalArgumentException not thrown despite null scope identifier.");
} catch (IllegalArgumentException ex) {}
assertNull(shouldBeNull);
/* Now test namespaces. */
// Null namespace (invalid).
factory.setNamespace(null);
try {
shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
fail("Expected IllegalArgumentException not thrown despite null OntoNet namespace.");
} catch (IllegalArgumentException ex) {}
assertNull(shouldBeNull);
// Namespace with query (invalid).
factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology/?query=true"));
try {
shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
fail("Expected IllegalArgumentException not thrown despite query in OntoNet namespace.");
} catch (IllegalArgumentException ex) {}
assertNull(shouldBeNull);
// Namespace with fragment (invalid).
factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology#fragment"));
try {
shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
fail("Expected IllegalArgumentException not thrown despite fragment in OntoNet namespace.");
} catch (IllegalArgumentException ex) {}
assertNull(shouldBeNull);
// Namespace ending with hash (invalid).
factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology#"));
try {
shouldBeNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
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.setNamespace(IRI.create("http://stanbol.apache.org/ontology"));
shouldBeNotNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
assertNotNull(shouldBeNotNull);
assertTrue(shouldBeNotNull.getNamespace().toString().endsWith("/"));
shouldBeNotNull = null;
// Namespace ending with slash (valid).
factory.setNamespace(IRI.create("http://stanbol.apache.org/ontology/"));
shouldBeNotNull = factory.createOntologySpace("Sc0p3", SpaceType.CORE, new BlankOntologySource());
assertNotNull(shouldBeNotNull);
}