use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestPrefixMappingAssembler method testIncludesSingleMapping.
public void testIncludesSingleMapping() {
PrefixMapping wanted = PrefixMapping.Factory.create().setNsPrefix("pre", "some:prefix/");
Assembler a = new PrefixMappingAssembler();
Resource root = resourceInModel("root rdf:type ja:PrefixMapping; root ja:includes pm" + "; pm rdf:type ja:PrefixMapping; pm ja:prefix 'pre'; pm ja:namespace 'some:prefix/'");
PrefixMapping pm = (PrefixMapping) a.open(root);
assertSamePrefixMapping(wanted, pm);
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestLocationMapperAssembler method testCreatesLocationMapper.
public void testCreatesLocationMapper() {
Resource root = resourceInModel("r rdf:type ja:LocationMapper");
Assembler a = new LocationMapperAssembler();
Object x = a.open(root);
assertInstanceOf(LocationMapper.class, x);
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestReasoners method testTransitiveBindReuse.
/**
* 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 that the transitive reasoner state reuse has been fixed at source.
*/
public void testTransitiveBindReuse() {
Reasoner r = ReasonerRegistry.getTransitiveReasoner();
InfModel om1 = ModelFactory.createInfModel(r, ModelFactory.createDefaultModel());
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());
InfModel om2 = ModelFactory.createInfModel(r, ModelFactory.createDefaultModel());
StmtIterator si = om2.listStatements();
boolean ok = !si.hasNext();
si.close();
assertTrue("Transitive reasoner state leak", ok);
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestReasoners method testTransitiveCycleBug.
/**
* Cycle bug in transitive reasoner
*/
public void testTransitiveCycleBug() {
Model m = FileManager.get().loadModel("file:testing/reasoners/bugs/unbroken.n3");
OntModel om = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM_TRANS_INF, m);
OntClass rootClass = om.getOntClass(RDFS.Resource.getURI());
Resource c = m.getResource("c");
Set<OntClass> direct = rootClass.listSubClasses(true).toSet();
assertFalse(direct.contains(c));
}
use of org.apache.jena.rdf.model.Resource in project jena by apache.
the class TestReasoners method testTransitiveEngineSeparation.
/**
* Test that two transitive engines are independent.
* See JENA-1260
*/
public void testTransitiveEngineSeparation() throws InterruptedException {
String NS = "http://example.com/test#";
Property sp = ResourceFactory.createProperty(NS, "sp");
Property p = ResourceFactory.createProperty(NS, "p");
Property s = ResourceFactory.createProperty(NS, "s");
Resource q = ResourceFactory.createProperty(NS, "q");
Reasoner reasoner = ReasonerRegistry.getTransitiveReasoner();
InfModel simple = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel());
simple.add(s, sp, p);
assertFalse(simple.contains(s, RDFS.subPropertyOf, p));
InfModel withSP = ModelFactory.createInfModel(reasoner, ModelFactory.createDefaultModel());
withSP.add(sp, RDFS.subPropertyOf, RDFS.subPropertyOf);
withSP.add(s, sp, p);
assertTrue(withSP.contains(s, RDFS.subPropertyOf, p));
simple.add(q, sp, p);
assertFalse(simple.contains(q, RDFS.subPropertyOf, p));
}
Aggregations