use of org.apache.jena.rdf.model.Model in project jena by apache.
the class QueryTest method createDataset.
private static Dataset createDataset(List<String> defaultGraphURIs, List<String> namedGraphURIs) {
// Allow "qt:data" to be quads in defaultGraphURIs.
Dataset ds = DatasetFactory.createGeneral();
if (defaultGraphURIs != null) {
for (String sourceURI : defaultGraphURIs) {
RDFDataMgr.read(ds, sourceURI);
}
}
if (namedGraphURIs != null) {
for (String sourceURI : namedGraphURIs) {
String absSourceURI = IRIResolver.resolveString(sourceURI);
Model m = ds.getNamedModel(absSourceURI);
RDFDataMgr.read(m, sourceURI);
}
}
return ds;
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class GraphsTests method fillDataset.
protected void fillDataset(Dataset dataset) {
// Load default model.
// Load graph 1
// Load graph 2.
dataset.getDefaultModel().getGraph().add(SSE.parseTriple("(<x> <p> 'Default graph')"));
Model m1 = dataset.getNamedModel(graph1);
m1.getGraph().add(SSE.parseTriple("(<x> <p> 'Graph 1')"));
m1.getGraph().add(SSE.parseTriple("(<x> <p> 'ZZZ')"));
Model m2 = dataset.getNamedModel(graph2);
m2.getGraph().add(SSE.parseTriple("(<x> <p> 'Graph 2')"));
m2.getGraph().add(SSE.parseTriple("(<x> <p> 'ZZZ')"));
calcUnion.add(m1);
calcUnion.add(m2);
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class QueryTest method compareGraphResults.
private void compareGraphResults(Model resultsActual, Query query) {
if (results != null) {
try {
if (!results.isGraph())
fail("Expected results are not a graph: " + testItem.getName());
Model resultsExpected = results.getModel();
if (!resultsExpected.isIsomorphicWith(resultsActual)) {
printFailedModelTest(query, resultsExpected, resultsActual);
fail("Results do not match: " + testItem.getName());
}
} catch (Exception ex) {
String typeName = (query.isConstructType() ? "construct" : "describe");
fail("Exception in result testing (" + typeName + "): " + ex);
}
}
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class QueryTest method runTestDescribe.
void runTestDescribe(Query query, QueryExecution qe) {
Model resultsActual = qe.execDescribe();
compareGraphResults(resultsActual, query);
}
use of org.apache.jena.rdf.model.Model in project jena by apache.
the class TestUpdateOperations method insert_where_01.
@Test
public void insert_where_01() {
Model m = ModelFactory.createDefaultModel();
Resource anon = m.createResource();
anon.addProperty(RDF.type, OWL.Thing);
assertEquals(1, m.size());
UpdateRequest req = UpdateFactory.create("INSERT { ?s ?p ?o } WHERE { ?o ?p ?s }");
UpdateAction.execute(req, m);
assertEquals(2, m.size());
assertEquals(1, m.listStatements(anon, null, (RDFNode) null).toList().size());
assertEquals(1, m.listStatements(null, null, anon).toList().size());
}
Aggregations