Search in sources :

Example 31 with ResultSet

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

the class TestResultSet method test_RS_union_1.

@Test
public void test_RS_union_1() {
    ResultSet rs1 = make("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
    ResultSet rs2 = make("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
    ResultSet rs3 = make2("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
    assertTrue(ResultSetCompare.equalsByTerm(rs3, 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 32 with ResultSet

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

the class TestResultSetFormat2 method parseTSV.

private void parseTSV(String x) {
    byte[] b = StrUtils.asUTF8bytes(x);
    ByteArrayInputStream in = new ByteArrayInputStream(b);
    ResultSet rs2 = ResultSetFactory.fromTSV(in);
    while (rs2.hasNext()) {
        rs2.nextBinding();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ResultSet(org.apache.jena.query.ResultSet)

Example 33 with ResultSet

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

the class TestResultSet method test_RS_8.

@Test
public void test_RS_8() {
    ResultSet rs = ResultSetFactory.load("testing/ResultSet/output.srx");
    test_RS_fmt(rs, ResultsFormat.FMT_RS_JSON, true);
}
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 34 with ResultSet

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

the class TestResultSet method test_RS_10.

@Test
public void test_RS_10() {
    ResultSet rs = ResultSetFactory.load("testing/ResultSet/output.srx");
    for (; rs.hasNext(); rs.next()) {
    }
    // We should be able to call hasNext() as many times as we want!
    assertFalse(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 35 with ResultSet

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

the class TestResultSet method make2.

private ResultSet make2(String var, Node val) {
    BindingMap b1 = BindingFactory.create();
    b1.add(Var.alloc(var), val);
    BindingMap b2 = BindingFactory.create();
    b2.add(Var.alloc(var), val);
    List<String> vars = new ArrayList<>();
    vars.add(var);
    List<Binding> solutions = new ArrayList<>();
    solutions.add(b1);
    solutions.add(b2);
    QueryIterator qIter = new QueryIterPlainWrapper(solutions.iterator(), null);
    ResultSet rs = new ResultSetStream(vars, null, qIter);
    return rs;
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryIterPlainWrapper(org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper) 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)75 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)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 QuerySolution (org.apache.jena.query.QuerySolution)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 Query (org.apache.jena.query.Query)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 Binding (org.apache.jena.sparql.engine.binding.Binding)4 AbstractRegexpBasedTest (org.apache.jena.arq.AbstractRegexpBasedTest)3