JenaOntologyService implements OntologyService { @Override public Ont getOntology(final URI uri) { return new Ont(resolveImports(ModelFactory.createOntologyModel(defaultSpec, load(uri.toString())))); } JenaOntologyService(); void setOntModelSpec(final OntModelSpec spec); @Reference void setRegistryDelegate(final OntologyRegistry registry); @Override Ont getOntology(final URI uri); @Override Ont parseOntology(final WebResource ont); @Override Ont merge(final Ontology ontology1, final Ontology ontology2); @Override Set<URI> inferClasses(final URI uri, final WebResource resource, final Ontology ontology);  }
@Test public void ontologyRetrievalTest() { final OntModel model = toTest.getOntology(URI.create(ONT1)).model; final Model expectedTriples = ModelFactory.createDefaultModel(); expectedTriples.read(ONTOLOGY_REGISTRY.get(URI.create(ONT1)).representation(), null, "N-TRIPLES"); assertTrue(model.containsAll(expectedTriples)); }
@Test public void followOwlImportsTest() { final OntModel model_includes_1_and_2 = toTest.getOntology(URI.create(ONT3)).model; final Model expectedTriples = ModelFactory.createDefaultModel(); expectedTriples.read(ONTOLOGY_REGISTRY.get(URI.create(ONT1)).representation(), null, "N-TRIPLES"); expectedTriples.read(ONTOLOGY_REGISTRY.get(URI.create(ONT2)).representation(), null, "N-TRIPLES"); expectedTriples.read(ONTOLOGY_REGISTRY.get(URI.create(ONT3)).representation(), null, "N-TRIPLES"); expectedTriples.removeAll(null, expectedTriples.getProperty(OWL_IMPORTS), null); assertTrue(model_includes_1_and_2.containsAll(expectedTriples)); }
@Test public void transitiveImportsTest() throws Exception { final OntModel transitive = toTest.getOntology(URI.create(ONT5)).model; final Model expectedTriples = ModelFactory.createDefaultModel(); expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT1)) .representation(), null, "N-TRIPLES")); expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT4)) .representation(), null, "N-TRIPLES")); expectedTriples.add(ModelFactory.createDefaultModel().read(ONTOLOGY_REGISTRY.get(URI.create(ONT5)) .representation(), null, "N-TRIPLES")); expectedTriples.removeAll(null, expectedTriples.getProperty(OWL_IMPORTS), null); assertTrue(transitive.containsAll(expectedTriples)); }