Search in sources :

Example 91 with ResultSet

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

the class TestResultSet method test_RS_cmp_3.

@Test
public void test_RS_cmp_3() {
    ResultSet rs1 = make("x", org.apache.jena.graph.NodeFactory.createURI("tag:local"));
    ResultSet rs2 = new ResultSetMem();
    assertFalse(ResultSetCompare.equalsByTerm(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 92 with ResultSet

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

the class TestResultSet method test_RS_7.

// Into some format.
@Test
public void test_RS_7() {
    ResultSet rs = ResultSetFactory.load("testing/ResultSet/output.srx");
    test_RS_fmt(rs, ResultsFormat.FMT_RS_XML, 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 93 with ResultSet

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

the class TestResultSet method test_RS_cmp_4.

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

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

the class TestResultSet method test_RS_peeking_5.

@Test
public void test_RS_peeking_5() {
    // 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")));
    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 there won't be further elements available anymore
    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 95 with ResultSet

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

the class FusekiConfig method servicesAndDatasets.

private static List<DataAccessPoint> servicesAndDatasets(Model model) {
    // Old style configuration file : server to services.
    DatasetDescriptionRegistry dsDescMap = FusekiServer.registryForBuild();
    // ---- Services
    ResultSet rs = FusekiLib.query("SELECT * { ?s fu:services [ list:member ?service ] }", model);
    List<DataAccessPoint> accessPoints = new ArrayList<>();
    if (!rs.hasNext())
        // No "fu:services ( .... )" so try looking for services directly.
        // This means Fuseki2, service configuration files (no server section) work for --conf. 
        rs = FusekiLib.query("SELECT ?service { ?service a fu:Service }", model);
    for (; rs.hasNext(); ) {
        QuerySolution soln = rs.next();
        Resource svc = soln.getResource("service");
        DataAccessPoint acc = FusekiBuilder.buildDataAccessPoint(svc, dsDescMap);
        accessPoints.add(acc);
    }
    return accessPoints;
}
Also used : QuerySolution(org.apache.jena.query.QuerySolution) ResultSet(org.apache.jena.query.ResultSet) ArrayList(java.util.ArrayList)

Aggregations

ResultSet (org.apache.jena.query.ResultSet)166 QuerySolution (org.apache.jena.query.QuerySolution)107 QueryExecution (org.apache.jena.query.QueryExecution)105 Test (org.junit.Test)98 ArrayList (java.util.ArrayList)73 Query (org.apache.jena.query.Query)51 Dataset (org.apache.jena.query.Dataset)43 Resource (org.apache.jena.rdf.model.Resource)41 Literal (org.apache.jena.rdf.model.Literal)20 BuilderResultSet (org.apache.jena.sparql.sse.builders.BuilderResultSet)17 Model (org.apache.jena.rdf.model.Model)14 ByteArrayInputStream (java.io.ByteArrayInputStream)12 BaseTest (org.apache.jena.atlas.junit.BaseTest)12 Node (org.apache.jena.graph.Node)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 HashMap (java.util.HashMap)8 RDFNode (org.apache.jena.rdf.model.RDFNode)8 IOException (java.io.IOException)7 InputStream (java.io.InputStream)6 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)6