Search in sources :

Example 11 with OntModel

use of org.apache.jena.ontology.OntModel in project jena by apache.

the class TestReasoners method testTransitiveSpecReuse.

/**
     * The reasoner contract for bind(data) is not quite precise. It allows for
     * reasoners which have state so that reusing the same reasoner on a second data
     * model might lead to interference. This in fact used to happen with the transitive
     * reasoner. This is a test to check the top level symptoms of this which can be
     * solved just be not reusing reasoners.
     * @todo this test might be better moved to OntModel tests somewhere
     */
public void testTransitiveSpecReuse() {
    OntModel om1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF);
    Resource c1 = om1.createResource(PrintUtil.egNS + "Class1");
    Resource c2 = om1.createResource(PrintUtil.egNS + "Class2");
    Resource c3 = om1.createResource(PrintUtil.egNS + "Class3");
    om1.add(c1, RDFS.subClassOf, c2);
    om1.add(c2, RDFS.subClassOf, c3);
    om1.prepare();
    assertFalse(om1.isEmpty());
    OntModel om2 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF);
    StmtIterator si = om2.listStatements();
    boolean ok = !si.hasNext();
    si.close();
    assertTrue("Transitive reasoner state leak", ok);
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) Resource(org.apache.jena.rdf.model.Resource) OntModel(org.apache.jena.ontology.OntModel)

Example 12 with OntModel

use of org.apache.jena.ontology.OntModel in project jena by apache.

the class TestInfModel method testListWithPosits.

/**
     * Check interface extensions which had an earlier bug with null handling
     */
public void testListWithPosits() {
    String NS = PrintUtil.egNS;
    Model data = ModelFactory.createDefaultModel();
    Resource c1 = data.createResource(NS + "C1");
    Resource c2 = data.createResource(NS + "C2");
    Resource c3 = data.createResource(NS + "C3");
    data.add(c2, RDFS.subClassOf, c3);
    Model premise = ModelFactory.createDefaultModel();
    premise.add(c1, RDFS.subClassOf, c2);
    InfModel im = ModelFactory.createInfModel(ReasonerRegistry.getRDFSReasoner(), data);
    TestUtil.assertIteratorValues(this, im.listStatements(c1, RDFS.subClassOf, null, premise), new Object[] { data.createStatement(c1, RDFS.subClassOf, c2), data.createStatement(c1, RDFS.subClassOf, c3), data.createStatement(c1, RDFS.subClassOf, c1) });
    OntModel om = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_RDFS_INF, data);
    TestUtil.assertIteratorValues(this, om.listStatements(c1, RDFS.subClassOf, null, premise), new Object[] { data.createStatement(c1, RDFS.subClassOf, c2), data.createStatement(c1, RDFS.subClassOf, c3), data.createStatement(c1, RDFS.subClassOf, c1) });
}
Also used : OntModel(org.apache.jena.ontology.OntModel) OntModel(org.apache.jena.ontology.OntModel)

Aggregations

OntModel (org.apache.jena.ontology.OntModel)12 Individual (org.apache.jena.ontology.Individual)3 Model (org.apache.jena.rdf.model.Model)2 Resource (org.apache.jena.rdf.model.Resource)2 Test (org.junit.Test)2 InputStream (java.io.InputStream)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 MediaType (javax.ws.rs.core.MediaType)1 BaseTest (org.apache.jena.atlas.junit.BaseTest)1 Triple (org.apache.jena.graph.Triple)1 DatatypeProperty (org.apache.jena.ontology.DatatypeProperty)1 ObjectProperty (org.apache.jena.ontology.ObjectProperty)1 OntClass (org.apache.jena.ontology.OntClass)1 OntModelImpl (org.apache.jena.ontology.impl.OntModelImpl)1 InfModel (org.apache.jena.rdf.model.InfModel)1 StmtIterator (org.apache.jena.rdf.model.StmtIterator)1 ValidityReport (org.apache.jena.reasoner.ValidityReport)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1