use of org.apache.jena.rdflink.RDFLink in project jena by apache.
the class TestService method service_query_bad_no_service.
@Test(expected = QueryExceptionHTTP.class)
public void service_query_bad_no_service() {
DatasetGraph dsg = env.dsg();
dsg.executeWrite(() -> dsg.add(SSE.parseQuad("(_ :s :p :o)")));
// Not a service of the dataset.
String queryString = "SELECT * { SERVICE <" + SERVICE + "/JUNK> { ?s ?p ?o }} ";
// Connect to local, unused, permanently empty dataset
try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
try (QueryExec qExec = link.query(queryString)) {
RowSet rs = qExec.select();
// Should go on execution.
rs.hasNext();
fail("Should not get here");
}
}
}
use of org.apache.jena.rdflink.RDFLink in project jena by apache.
the class TestService method service_query_bad_3.
@Test(expected = QueryExceptionHTTP.class)
public void service_query_bad_3() {
DatasetGraph dsg = env.dsg();
dsg.executeWrite(() -> dsg.add(SSE.parseQuad("(_ :s :p :o)")));
// Not a dataset of the server
String queryString = "SELECT * { SERVICE <http://nosuchsite/> { ?s ?p ?o }} ";
// Connect to local, unused, permanently empty dataset
try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
try (QueryExec qExec = link.query(queryString)) {
// Where it should go wrong.
RowSet rs = qExec.select();
// Should go on execution.
rs.hasNext();
fail("Should not get here");
}
}
}
use of org.apache.jena.rdflink.RDFLink in project jena by apache.
the class TestSetupHTTP method setup_RDFLink.
@Test
public void setup_RDFLink() {
try (RDFLink link = RDFLinkHTTP.service(URL).httpClient(httpClient).acceptHeaderGraph("application/rdf+xml").acceptHeaderDataset("application/n-quads").quadsFormat(Lang.NQ).triplesFormat(Lang.RDFXML).build()) {
link.load(g);
link.get();
link.loadDataset(dsg);
link.getDataset();
}
}
use of org.apache.jena.rdflink.RDFLink in project jena by apache.
the class ExModification01 method exampleMod.
private static void exampleMod() {
AtomicLong counter = new AtomicLong(0);
HttpRequestModifier modifier = (params, headers) -> {
long x = counter.incrementAndGet();
headers.put("X-Tracker", "Call=" + x);
};
RegistryRequestModifier.get().addPrefix(serverURL, modifier);
// RegistryRequestModifier.get().add(dataURL, modifier);
// GSP : NO MODIFICATION no call to modifyByService
// GSP : calls HttpRDF
// Pass in request or at least request type.
/*
org.apache.jena.http.sys.RegistryRequestModifier.get()
auth.examples.ExModification01.exampleMod()
org.apache.jena.http.HttpLib.modifyByService(String, Context, Params, Map<String, String>)
org.apache.jena.sparql.exec.http.UpdateExecHTTP.execute()
org.apache.jena.sparql.exec.http.QueryExecHTTP.query(String)
==> SERVICE via QueryExecHTTP
==> GSP ?
org.apache.jena.sparql.exec.http.TestService.runWithModifier(String, HttpRequestModifier, Runnable)
*/
GSP.service(dataURL).defaultGraph().GET();
try (RDFLink link = RDFLinkHTTP.service(dataURL).build()) {
boolean b = link.queryAsk("ASK{}");
}
}
Aggregations