use of org.apache.jena.ontology.ObjectProperty in project jena by apache.
the class JenaOSGITest method testJenaCore.
@Test
public void testJenaCore() throws Exception {
Model model = makeModel();
Writer writer = new StringWriter();
model.write(writer, "N-Triples");
assertEquals("<http://example.com/alice> <http://xmlns.com/foaf/0.1/knows> <http://example.com/bob> .", writer.toString().trim());
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
ObjectProperty knowsObjProp = ontModel.createObjectProperty(knows.getURI());
ObjectProperty hasFriend = ontModel.createObjectProperty("http://example.com/has_friend");
hasFriend.addSuperProperty(knowsObjProp);
Individual aliceIndividual = ontModel.createIndividual(alice);
Individual bobIndividiual = ontModel.createIndividual(bob);
ontModel.add(aliceIndividual, hasFriend, bobIndividiual);
assertTrue(aliceIndividual.hasProperty(knowsObjProp, bobIndividiual));
}
Aggregations