use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.
the class TestOntologyRegistry method setup.
/**
* Sets the registry and ontology network managers, which are immutable across tests.
*/
@BeforeClass
public static void setup() {
// We use a single Dictionary for storing all configurations.
final Dictionary<String, Object> config = new Hashtable<String, Object>();
config.put(OfflineConfiguration.ONTOLOGY_PATHS, new String[] { "/ontologies", "/ontologies/registry" });
OfflineConfiguration offline = new OfflineConfigurationImpl(config);
// The registry manager can be updated via calls to createModel()
regman = new RegistryManagerImpl(offline, new ClerezzaOntologyProvider(new SimpleTcProvider(), offline, Parser.getInstance()), config);
}
use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.
the class TestClerezzaSpaces method setup.
@BeforeClass
public static void setup() throws Exception {
offline = new OfflineConfigurationImpl(new Hashtable<String, Object>());
ScopeRegistry reg = new ScopeRegistryImpl();
// This one is created from scratch
Graph ont2 = ClerezzaOWLUtils.createOntology(baseIri2.toString());
minorSrc = new GraphSource(ont2.getImmutableGraph());
dropSrc = getLocalSource("/ontologies/droppedcharacters.owl");
nonexSrc = getLocalSource("/ontologies/nonexistentcharacters.owl");
inMemorySrc = new ParentPathInputSource(new File(TestClerezzaSpaces.class.getResource("/ontologies/maincharacters.owl").toURI()));
OWLDataFactory df = OWLManager.getOWLDataFactory();
OWLClass cHuman = df.getOWLClass(IRI.create(baseIri + "/" + Constants.humanBeing));
OWLIndividual iLinus = df.getOWLNamedIndividual(IRI.create(baseIri + "/" + Constants.linus));
linusIsHuman = df.getOWLClassAssertionAxiom(cHuman, iLinus);
factory = new ClerezzaCollectorFactory(new ClerezzaOntologyProvider(tcManager, offline, parser), new Hashtable<String, Object>());
factory.setDefaultNamespace(IRI.create("http://stanbol.apache.org/ontology/"));
}
use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.
the class MockOsgiContext method reset.
/**
* Sets up a new mock OSGi context and cleans all resources and components.
*/
public static void reset() {
// reset Clerezza objects
tcManager = new TcManager();
tcManager.addWeightedTcProvider(new SimpleTcProvider());
// reset Stanbol objects
ontologyProvider = new ClerezzaOntologyProvider(tcManager, offline, parser);
collectorfactory = new ClerezzaCollectorFactory(ontologyProvider, config);
resetManagers();
}
use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.
the class TestOntologyLibrary method testLibraryLoad.
/**
* Uses a plain {@link RegistryManager} to load a single ontology library and checks for its expected hits
* and misses.
*
* @throws Exception
* if any error occurs;
*/
@Test
public void testLibraryLoad() throws Exception {
IRI localTestRegistry = IRI.create(getClass().getResource(registryResourcePath));
Dictionary<String, Object> regmanConf = new Hashtable<String, Object>();
regmanConf.put(RegistryManager.REGISTRY_LOCATIONS, new String[] { localTestRegistry.toString() });
// Instantiating the registry manager will also load the registry data.
regMgr = new RegistryManagerImpl(offline, new ClerezzaOntologyProvider(tcManager, offline, parser), regmanConf);
// The resulting manager must exist and have exactly one registry.
assertNotNull(regMgr);
Set<Registry> registries = regMgr.getRegistries();
assertFalse(registries.isEmpty());
assertEquals(1, registries.size());
Registry reg = registries.iterator().next();
assertTrue(reg.hasChildren());
Library lib = null;
// Look for test #Library2
for (RegistryItem item : reg.getChildren()) {
if (Locations.LIBRARY_TEST2.equals(item.getIRI())) {
lib = (Library) item;
break;
}
}
assertNotNull(lib);
// Should be in the library.
boolean hasShould = RegistryUtils.containsOntologyRecursive(lib, Locations.CHAR_DROPPED);
// Should NOT be in the library (belongs to another library in the same registry).
boolean hasShouldNot = RegistryUtils.containsOntologyRecursive(lib, Locations.CHAR_ACTIVE);
assertTrue(hasShould);
assertFalse(hasShouldNot);
}
use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.ontology.ClerezzaOntologyProvider in project stanbol by apache.
the class TestOntologyLibrary method testLibrarySourceCreation.
/**
* Tests the creation of an ontology input source from a single library. Because the test is run offline,
* import statements might be file URIs, so tests should not fail on this.
*
* @throws Exception
*/
@Test
public void testLibrarySourceCreation() throws Exception {
IRI localTestRegistry = IRI.create(getClass().getResource(registryResourcePath));
Dictionary<String, Object> regmanConf = new Hashtable<String, Object>();
regmanConf.put(RegistryManager.REGISTRY_LOCATIONS, new String[] { localTestRegistry.toString() });
// Instantiating the registry manager will also load the registry data.
regMgr = new RegistryManagerImpl(offline, new ClerezzaOntologyProvider(tcManager, offline, parser), regmanConf);
assertNotNull(regMgr);
// Now use this registry manager to instantiate an input source.
OntologyInputSource<OWLOntology> src = new LibrarySource(Locations.LIBRARY_TEST1, regMgr, virginOntologyManager);
OWLOntology o = src.getRootOntology();
boolean hasImporting = false, hasImported = false;
for (OWLImportsDeclaration ax : o.getImportsDeclarations()) {
// Since we added a local IRI mapping, import statements might be using file: IRIs instead of
// HTTP, in which case IRI equality would fail. So it is enough here to just check the filename.
String tmpstr = ax.getIRI().toString();
if (!hasImporting && tmpstr.endsWith("characters_all.owl"))
hasImporting = true;
else if (!hasImported && tmpstr.endsWith("maincharacters.owl"))
hasImported = true;
if (hasImporting && hasImported)
break;
}
assertTrue(hasImporting);
assertTrue(hasImported);
}
Aggregations