use of org.apache.jena.rdflink.RDFLinkHTTPBuilder in project jena by apache.
the class TestRDFLinkFusekiBinary method rdflink_fuseki_1.
@Test
public void rdflink_fuseki_1() {
// Tests all run, in order, on one connection.
Triple triple = SSE.parseTriple("(:s :p <_:b3456>)");
Graph graph = GraphFactory.createDefaultGraph();
graph.add(triple);
FusekiServer server = createFusekiServer().build().start();
int port = server.getPort();
try {
String dsURL = "http://localhost:" + port + "/ds";
assertTrue(HttpLib.isFuseki(dsURL));
RDFLinkHTTPBuilder builder = RDFLinkFuseki.newBuilder().destination(dsURL);
try (RDFLinkFuseki link = (RDFLinkFuseki) builder.build()) {
// assertTrue(isFuseki(link));
// GSP
link.put(graph);
checkGraph(link, "b3456");
// Query forms.
link.querySelect("SELECT * {?s ?p ?o}", x -> {
Node obj = x.get(Var.alloc("o"));
assertTrue(obj.isBlank());
assertEquals("b3456", obj.getBlankNodeLabel());
});
try (QueryExec qExec = link.query("ASK {?s ?p <_:b3456>}")) {
boolean bool = qExec.ask();
assertTrue(bool);
}
try (QueryExec qExec = link.query("CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o . FILTER (sameTerm(?o, <_:b3456>)) }")) {
Graph graph2 = qExec.construct();
checkGraph(graph2, "b3456");
}
try (QueryExec qExec = link.query("DESCRIBE ?s WHERE { ?s ?p <_:b3456>}")) {
Graph graph2 = qExec.describe();
checkGraph(graph2, "b3456");
}
// Update
link.update("CLEAR DEFAULT");
link.update("INSERT DATA { <x:s> <x:p> <_:b789> }");
checkGraph(link, "b789");
link.update("CLEAR DEFAULT");
link.update("INSERT DATA { <x:s> <x:p> <_:6789> }");
checkGraph(link, "6789");
}
} finally {
server.stop();
}
}
Aggregations