use of org.apache.jena.query.ResultSetRewindable 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.ResultSetRewindable in project jena by apache.
the class TestResultSet method test_RS_cmp_6.
@Test
public void test_RS_cmp_6() {
// Different variable, same values
ResultSetRewindable rs1 = makeRewindable("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
ResultSetRewindable rs2 = makeRewindable("y", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
assertFalse(ResultSetCompare.equalsByTermAndOrder(rs1, rs2));
rs1.reset();
rs2.reset();
assertFalse(ResultSetCompare.equalsByTerm(rs1, rs2));
}
use of org.apache.jena.query.ResultSetRewindable in project jena by apache.
the class TestResultSetFormat1 method areIsomorphic.
private static void areIsomorphic(ResultSet x, ResultSet y) {
ResultSetRewindable rs1 = ResultSetFactory.makeRewindable(x);
ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(y);
// System.out.println(ResultSetFormatter.asText(rs1));
// System.out.println();
// System.out.println(ResultSetFormatter.asText(rs2));
// rs1.reset();
// rs2.reset();
Assert.assertTrue(ResultSetCompare.isomorphic(rs1, rs2));
}
use of org.apache.jena.query.ResultSetRewindable in project jena by apache.
the class TestResultSet method test_RS_peeking_8.
@Test(expected = IllegalStateException.class)
public void test_RS_peeking_8() {
// Peeking may fail if someone moves backwards in the result set
// If we had moved past the first item this should be an error
ResultSetRewindable 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());
assertNotNull(rs.next());
// Reset the inner result set independently
inner.reset();
// Since we moved the underlying result set backwards and had moved somewhere we
// are now in an illegal state
rs.hasNext();
}
use of org.apache.jena.query.ResultSetRewindable in project jena by apache.
the class TestResultSet method test_RS_fmt.
private void test_RS_fmt(ResultSet rs, ResultsFormat fmt, boolean ordered) {
ResultSetRewindable rs1 = ResultSetFactory.makeRewindable(rs);
ByteArrayOutputStream arr = new ByteArrayOutputStream();
ResultSetFormatter.output(arr, rs1, fmt);
byte[] bytes = arr.toByteArray();
rs1.reset();
ByteArrayInputStream ins = new ByteArrayInputStream(bytes);
ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(ResultSetFactory.load(ins, fmt));
// Ordered? Unordered?
boolean b = ResultSetCompare.equalsByTerm(rs1, rs2);
if (ordered) {
rs1.reset();
rs2.reset();
b = b & ResultSetCompare.equalsByTerm(rs1, rs2);
}
if (!b) {
System.out.println(new String(bytes));
rs1.reset();
rs2.reset();
ResultSetFormatter.out(rs1);
ResultSetFormatter.out(rs2);
}
assertTrue(b);
}
Aggregations