use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class TestSPARQLProtocol method update_02.
@Test
public void update_02() {
UpdateRequest update = UpdateFactory.create("INSERT DATA {}");
UpdateProcessor proc = UpdateExecutionFactory.createRemoteForm(update, serviceUpdate());
proc.execute();
}
use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class FusekiTestServer method resetServer.
/*package*/
static void resetServer() {
if (countServer.get() == 0)
throw new RuntimeException("No server started!");
if (CLEAR_DSG_DIRECTLY) {
Txn.executeWrite(dsgTesting, () -> dsgTesting.clear());
} else {
Update clearRequest = new UpdateDrop(Target.ALL);
UpdateProcessor proc = UpdateExecutionFactory.createRemote(clearRequest, serviceUpdate());
try {
proc.execute();
} catch (Throwable e) {
e.printStackTrace();
throw e;
}
}
}
use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class TestSPARQLProtocol method update_01.
@Test
public void update_01() {
UpdateRequest update = UpdateFactory.create("INSERT DATA {}");
UpdateProcessor proc = UpdateExecutionFactory.createRemote(update, serviceUpdate());
proc.execute();
}
use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class AbstractTestDatasetWithTextIndexBase method doUpdate.
protected void doUpdate(String updateString) {
dataset.begin(ReadWrite.WRITE);
UpdateRequest request = UpdateFactory.create(updateString);
UpdateProcessor proc = UpdateExecutionFactory.create(request, dataset);
proc.execute();
dataset.commit();
}
use of org.apache.jena.update.UpdateProcessor in project jena by apache.
the class TestParameterizedSparqlString method test_param_string_bnode_3.
@Test
public void test_param_string_bnode_3() {
// Test case related to treatment of blank nodes when injecting into
// SPARQL updates using _: syntax
Model model = ModelFactory.createDefaultModel();
Resource bnode = model.createResource();
bnode.addProperty(RDF.type, OWL.Thing);
Assert.assertEquals(1, model.size());
Dataset ds = DatasetFactory.create(model);
// Use a parameterized query to check the data can be found
ParameterizedSparqlString pq = new ParameterizedSparqlString();
pq.setCommandText("SELECT * WHERE { ?s ?p ?o }");
pq.setIri("s", "_:" + bnode.getId());
Query q = pq.asQuery();
try (QueryExecution qe = QueryExecutionFactory.create(q, ds)) {
ResultSet rset = qe.execSelect();
Assert.assertEquals(1, ResultSetFormatter.consume(rset));
}
// Use a parameterized update to modify the data
ParameterizedSparqlString s = new ParameterizedSparqlString();
s.setCommandText("INSERT { ?o ?p ?s } WHERE { ?s ?p ?o }");
s.setIri("s", "_:" + bnode.getId());
UpdateRequest query = s.asUpdate();
UpdateProcessor proc = UpdateExecutionFactory.create(query, ds);
proc.execute();
// This should be true because this was present in the intial model set
// up
Assert.assertEquals(1, model.listStatements(bnode, null, (RDFNode) null).toList().size());
// This should return 0 because the INSERT should result in a new blank
// node being created rather than the existing one being reused becaue
// of the semantics of blank nodes usage in templates
Assert.assertEquals(0, model.listStatements(null, null, bnode).toList().size());
}
Aggregations