Search in sources :

Example 26 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TestResultSetFormat1 method resultset_05.

@Test
public void resultset_05() {
    ResultSet rs = make($rs);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ResultSetFormatter.outputAsCSV(out, rs);
}
Also used : BuilderResultSet(org.apache.jena.sparql.sse.builders.BuilderResultSet) ResultSet(org.apache.jena.query.ResultSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 27 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TestResultSetFormat1 method resultset_02.

@Test
public void resultset_02() {
    ResultSet rs = make($rs);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ResultSetFormatter.outputAsXML(out, rs);
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    ResultSet rs2 = ResultSetFactory.fromXML(in);
    areIsomorphic(rs, rs2);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BuilderResultSet(org.apache.jena.sparql.sse.builders.BuilderResultSet) ResultSet(org.apache.jena.query.ResultSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 28 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TestResultSet method test_RS_union_2.

@Test(expected = ResultSetException.class)
public void test_RS_union_2() {
    ResultSet rs1 = make("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
    ResultSet rs2 = make("y", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
    ResultSetUtils.union(rs1, rs2);
}
Also used : BuilderResultSet(org.apache.jena.sparql.sse.builders.BuilderResultSet) ResultSet(org.apache.jena.query.ResultSet) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 29 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TestResultSet method test_RS_peeking_6.

@Test
public void test_RS_peeking_6() {
    // 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")), 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 we'll be out of sync
    // but there should still be further data available
    assertTrue(rs.hasNext());
}
Also used : BuilderResultSet(org.apache.jena.sparql.sse.builders.BuilderResultSet) ResultSet(org.apache.jena.query.ResultSet) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 30 with ResultSet

use of org.apache.jena.query.ResultSet in project jena by apache.

the class TestResultSet method make.

private ResultSet make(String var1, Node val1, String var2, Node val2) {
    BindingMap b = BindingFactory.create();
    b.add(Var.alloc(var1), val1);
    b.add(Var.alloc(var2), val2);
    List<String> vars = new ArrayList<>();
    vars.add(var1);
    vars.add(var2);
    QueryIterator qIter = QueryIterSingleton.create(b, null);
    ResultSet rs = new ResultSetStream(vars, null, qIter);
    return rs;
}
Also used : QueryIterator(org.apache.jena.sparql.engine.QueryIterator) ArrayList(java.util.ArrayList) BuilderResultSet(org.apache.jena.sparql.sse.builders.BuilderResultSet) ResultSet(org.apache.jena.query.ResultSet) BindingMap(org.apache.jena.sparql.engine.binding.BindingMap) ResultSetStream(org.apache.jena.sparql.engine.ResultSetStream)

Aggregations

ResultSet (org.apache.jena.query.ResultSet)79 Test (org.junit.Test)43 BuilderResultSet (org.apache.jena.sparql.sse.builders.BuilderResultSet)33 BaseTest (org.apache.jena.atlas.junit.BaseTest)27 QueryExecution (org.apache.jena.query.QueryExecution)18 QuerySolution (org.apache.jena.query.QuerySolution)15 ByteArrayInputStream (java.io.ByteArrayInputStream)13 Query (org.apache.jena.query.Query)11 ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)8 ResultSetStream (org.apache.jena.sparql.engine.ResultSetStream)8 ArrayList (java.util.ArrayList)7 Node (org.apache.jena.graph.Node)7 Model (org.apache.jena.rdf.model.Model)6 ConfigTest (org.apache.jena.tdb.ConfigTest)6 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)5 Var (org.apache.jena.sparql.core.Var)5 NodeAlignment (mom.trd.opentheso.bdd.helper.nodes.NodeAlignment)4 Binding (org.apache.jena.sparql.engine.binding.Binding)4