use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSet method test_RS_cmp_4.
@Test
public void test_RS_cmp_4() {
ResultSet rs1 = make("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
ResultSet rs2 = make("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2));
assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2));
}
use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSet method test_RS_3.
// RDF
@Test
public void test_RS_3() {
ResultSetRewindable rs1 = new ResultSetMem();
Model model = RDFOutput.encodeAsModel(rs1);
rs1.reset();
ResultSet rs2 = RDFInput.fromRDF(model);
assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2));
}
use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSet method test_RS_peeking_5.
@Test
public void test_RS_peeking_5() {
// Peeking should be able to cope with people moving on the underlying result set independently
ResultSet inner = new ResultSetMem(make("x", NodeFactory.createURI("tag:local")), make("x", NodeFactory.createURI("tag:local")));
ResultSetPeekable rs = ResultSetFactory.makePeekable(inner);
assertTrue(rs.hasNext());
assertNotNull(rs.peek());
// Move on the inner result set independently
inner.next();
// Since we fiddled with the underlying result set there won't be further elements available anymore
assertFalse(rs.hasNext());
}
use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSet method test_RS_1.
// Test reading, writing and comparison
@Test
public void test_RS_1() {
ResultSetRewindable rs1 = new ResultSetMem();
ByteArrayOutputStream arr = new ByteArrayOutputStream();
ResultSetFormatter.outputAsXML(arr, rs1);
rs1.reset();
ByteArrayInputStream ins = new ByteArrayInputStream(arr.toByteArray());
ResultSet rs2 = ResultSetFactory.fromXML(ins);
assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2));
}
use of org.apache.jena.query.ResultSet in project jena by apache.
the class FusekiConfig method servicesAndDatasets.
private static List<DataAccessPoint> servicesAndDatasets(Model model) {
// Old style configuration file : server to services.
DatasetDescriptionRegistry dsDescMap = FusekiServer.registryForBuild();
// ---- Services
ResultSet rs = FusekiLib.query("SELECT * { ?s fu:services [ list:member ?service ] }", model);
List<DataAccessPoint> accessPoints = new ArrayList<>();
if (!rs.hasNext())
// No "fu:services ( .... )" so try looking for services directly.
// This means Fuseki2, service configuration files (no server section) work for --conf.
rs = FusekiLib.query("SELECT ?service { ?service a fu:Service }", model);
for (; rs.hasNext(); ) {
QuerySolution soln = rs.next();
Resource svc = soln.getResource("service");
DataAccessPoint acc = FusekiBuilder.buildDataAccessPoint(svc, dsDescMap);
accessPoints.add(acc);
}
return accessPoints;
}
Aggregations