Search in sources :

Example 11 with ResultSetRewindable

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;
}
Also used : BuilderResultSet(org.apache.jena.sparql.sse.builders.BuilderResultSet) ResultSet(org.apache.jena.query.ResultSet) ResultSetRewindable(org.apache.jena.query.ResultSetRewindable)

Example 12 with ResultSetRewindable

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));
}
Also used : ResultSetRewindable(org.apache.jena.query.ResultSetRewindable) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 13 with ResultSetRewindable

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));
}
Also used : ResultSetRewindable(org.apache.jena.query.ResultSetRewindable)

Example 14 with ResultSetRewindable

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();
}
Also used : ResultSetRewindable(org.apache.jena.query.ResultSetRewindable) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 15 with ResultSetRewindable

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ResultSetRewindable(org.apache.jena.query.ResultSetRewindable) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)32 Test (org.junit.Test)18 BaseTest (org.apache.jena.atlas.junit.BaseTest)17 ResultSet (org.apache.jena.query.ResultSet)11 BuilderResultSet (org.apache.jena.sparql.sse.builders.BuilderResultSet)11 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 QuerySolution (org.apache.jena.query.QuerySolution)5 Extractor (infoeval.main.WikiData.Extractor)3 RDFNode (org.apache.jena.rdf.model.RDFNode)3 Model (org.apache.jena.rdf.model.Model)2 SqlTablesFiller (infoeval.main.WikiData.SqlTablesFiller)1 Date (java.sql.Date)1 ArrayList (java.util.ArrayList)1 Item (org.apache.jena.sparql.sse.Item)1 Ignore (org.junit.Ignore)1