use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class TestService method service_query_disabled_queryexec.
@Test(expected = QueryExecException.class)
public void service_query_disabled_queryexec() {
String queryString = "ASK { SERVICE <" + SERVICE + "?format=json> { BIND(now() AS ?now) } }";
Context context = Context.create().set(Service.httpServiceAllowed, false);
try (QueryExec qExec = QueryExec.dataset(localDataset()).query(queryString).context(context).build()) {
qExec.ask();
}
}
use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class TestService method service_query_silent_nosite.
@Test
public void service_query_silent_nosite() {
logOnlyErrors(QueryIterService.class, () -> {
DatasetGraph dsg = env.dsg();
String queryString = "SELECT * { SERVICE SILENT <http://nosuchsite/> { VALUES ?X { 1 2 } }} ";
try (RDFLink link = RDFLinkFactory.connect(localDataset())) {
try (QueryExec qExec = link.query(queryString)) {
RowSet rs = qExec.select();
assertTrue(rs.hasNext());
Binding binding = rs.next();
assertFalse(rs.hasNext());
assertTrue(binding.isEmpty());
}
}
});
}
use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class AbstractTestRDFLink method query_02.
@Test
public void query_02() {
try (RDFLink link = link()) {
Txn.executeRead(link, () -> {
try (QueryExec qExec = link.query("ASK{}")) {
boolean b = qExec.ask();
assertTrue(b);
}
});
}
}
use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class AbstractTestRDFLink method query_03.
@Test
public void query_03() {
try (RDFLink link = link()) {
Txn.executeRead(link, () -> {
try (QueryExec qExec = link.query("CONSTRUCT WHERE{}")) {
Graph g = qExec.construct();
assertNotNull(g);
}
});
}
}
use of org.apache.jena.sparql.exec.QueryExec in project jena by apache.
the class AbstractTestRDFLink method query_build_02.
@Test
public void query_build_02() {
try (RDFLink link = link()) {
Txn.executeRead(link, () -> {
Binding binding = SSE.parseBinding("(binding (?X 123))");
QueryExec qExec = link.newQuery().query("SELECT ?X { }").substitution(binding).build();
RowSet rs = qExec.select();
Node x = rs.next().get(Var.alloc("X"));
assertNotNull(x);
});
}
}
Aggregations