use of org.apache.jena.rdf.model.StmtIterator in project jena by apache.
the class TestModelEvents method testAddStatementIterator.
public void testAddStatementIterator() {
model.register(SL);
final Statement[] sa = ModelHelper.statements(model, "x R y; a P b; x R y");
final StmtIterator it = asIterator(sa);
model.add(it);
SL.assertHas(new Object[] { "addIterator", Arrays.asList(sa) });
}
use of org.apache.jena.rdf.model.StmtIterator in project jena by apache.
the class TestReaders method testReadLocalNTriple.
public void testReadLocalNTriple() {
model.read(getInputStream("TestReaders.nt"), "", "N-TRIPLE");
Assert.assertEquals("Wrong size model", 5, model.size());
final StmtIterator iter = model.listStatements(null, null, "foo\"\\\n\r\tbar");
Assert.assertTrue("No next statement found", iter.hasNext());
}
use of org.apache.jena.rdf.model.StmtIterator 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);
}
use of org.apache.jena.rdf.model.StmtIterator in project jena by apache.
the class TestReasoners method testModelFactoryRDFS.
/**
* Test the ModelFactory interface
*/
public void testModelFactoryRDFS() {
Model data = ModelFactory.createDefaultModel();
Property p = data.createProperty("urn:x-hp:ex/p");
Resource a = data.createResource("urn:x-hp:ex/a");
Resource b = data.createResource("urn:x-hp:ex/b");
Resource C = data.createResource("urn:x-hp:ex/c");
data.add(p, RDFS.range, C).add(a, p, b);
Model result = ModelFactory.createRDFSModel(data);
StmtIterator i = result.listStatements(b, RDF.type, (RDFNode) null);
TestUtil.assertIteratorValues(this, i, new Object[] { data.createStatement(b, RDF.type, RDFS.Resource), data.createStatement(b, RDF.type, C) });
}
use of org.apache.jena.rdf.model.StmtIterator in project jena by apache.
the class UnionModelAssembler method addSubModels.
private void addSubModels(Assembler a, Resource root, MultiUnion union, Mode mode) {
for (StmtIterator it = root.listProperties(JA.subModel); it.hasNext(); ) {
Resource resource = getResource(it.nextStatement());
union.addGraph(a.openModel(resource, mode).getGraph());
}
}
Aggregations