use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSet method test_RS_peeking_9.
@Test
public void test_RS_peeking_9() {
// Check that peeking causes the correct row to be returned when we actually access the rows
Node first = NodeFactory.createURI("tag:first");
Node second = NodeFactory.createURI("tag:second");
Var x = Var.alloc("x");
ResultSet inner = new ResultSetMem(make("x", first), make("x", second));
ResultSetPeekable rs = ResultSetFactory.makePeekable(inner);
assertTrue(rs.hasNext());
// Peek and check row is as expected
Binding peeked = rs.peekBinding();
assertNotNull(peeked);
assertTrue(first.equals(peeked.get(x)));
// Check first row is as expected
Binding next = rs.nextBinding();
assertNotNull(next);
assertTrue(first.equals(next.get(x)));
// Repeat for second row
peeked = rs.peekBinding();
assertNotNull(peeked);
assertTrue(second.equals(peeked.get(x)));
next = rs.nextBinding();
assertNotNull(next);
assertTrue(second.equals(next.get(x)));
}
use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSet method test_RS_2_str.
@Test
public void test_RS_2_str() {
ResultSetRewindable rs1 = makeRewindable("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
String x = ResultSetFormatter.asXMLString(rs1);
rs1.reset();
ResultSet rs2 = ResultSetFactory.fromXML(x);
assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2));
}
use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSet method makeRewindable.
private ResultSetRewindable makeRewindable(String var, Node val) {
ResultSet rs = make(var, val);
ResultSetRewindable rsw = ResultSetFactory.makeRewindable(rs);
return rsw;
}
use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSet method makePeekable.
private ResultSetPeekable makePeekable(String var, Node val) {
ResultSet rs = make(var, val);
ResultSetPeekable rsp = ResultSetFactory.makePeekable(rs);
return rsp;
}
use of org.apache.jena.query.ResultSet in project jena by apache.
the class TestResultSetFormat1 method resultset_03.
@Test
public void resultset_03() {
ResultSet rs = make($rs);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ResultSetFormatter.outputAsJSON(out, rs);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
ResultSet rs2 = ResultSetFactory.fromJSON(in);
areIsomorphic(rs, rs2);
}
Aggregations