use of org.apache.jena.rdfconnection.RDFConnectionFuseki in project jena by apache.
the class TestRDFConnectionFusekiBinary method rdfconnection_fuseki_1.
@Test
public void rdfconnection_fuseki_1() {
// Tests all run, in order, on one connection.
Triple triple = SSE.parseTriple("(:s :p <_:b3456>)");
// Goes in as URI! (pre this PR)
Model model = ModelFactory.createDefaultModel();
model.getGraph().add(triple);
int PORT = WebLib.choosePort();
FusekiServer server = createFusekiServer(PORT).build().start();
try {
String dsURL = "http://localhost:" + PORT + "/ds";
assertTrue(HttpLib.isFuseki(dsURL));
RDFConnectionRemoteBuilder builder = RDFConnectionFuseki.create().destination(dsURL);
try (RDFConnectionFuseki conn = (RDFConnectionFuseki) builder.build()) {
assertTrue(HttpLib.isFuseki(dsURL));
// GSP
conn.put(model);
checkModel(conn, "b3456");
// Query forms.
conn.querySelect("SELECT * {?s ?p ?o}", x -> {
Node obj = x.get("o").asNode();
assertTrue(obj.isBlank());
assertEquals("b3456", obj.getBlankNodeLabel());
});
try (QueryExecution qExec = conn.query("ASK {?s ?p <_:b3456>}")) {
boolean bool = qExec.execAsk();
assertTrue(bool);
}
try (QueryExecution qExec = conn.query("CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER (sameTerm(?o, <_:b3456>)) }")) {
Model model2 = qExec.execConstruct();
checkModel(model2, "b3456");
}
try (QueryExecution qExec = conn.query("DESCRIBE ?s WHERE { ?s ?p <_:b3456>}")) {
Model model2 = qExec.execConstruct();
checkModel(model2, "b3456");
}
// Update
conn.update("CLEAR DEFAULT");
conn.update("INSERT DATA { <x:s> <x:p> <_:b789> }");
checkModel(conn, "b789");
conn.update("CLEAR DEFAULT");
conn.update("INSERT DATA { <x:s> <x:p> <_:6789> }");
checkModel(conn, "6789");
}
} finally {
server.stop();
}
}
use of org.apache.jena.rdfconnection.RDFConnectionFuseki in project jena by apache.
the class RDFConnectionExample6 method main.
public static void main(String... args) {
RDFConnectionRemoteBuilder builder = RDFConnectionFuseki.create().destination("http://sparql.org/sparql");
Query query = QueryFactory.create("SELECT * { BIND('Hello'as ?text) }");
// In this variation, a connection is built each time.
try (RDFConnectionFuseki conn = (RDFConnectionFuseki) builder.build()) {
conn.queryResultSet(query, ResultSetFormatter::out);
}
}
Aggregations