Search in sources :

Example 6 with ResultSet

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

the class StoreUtils method containsGraph.

public static boolean containsGraph(Store store, Node graphNode) {
    String qs = "SELECT * { GRAPH " + FmtUtils.stringForNode(graphNode) + " { ?s ?p ?o }} LIMIT 1";
    Dataset ds = SDBFactory.connectDataset(store);
    try (QueryExecution qExec = QueryExecutionFactory.create(qs, ds)) {
        ResultSet rs = qExec.execSelect();
        return rs.hasNext();
    }
}
Also used : Dataset(org.apache.jena.query.Dataset) ResultSet(org.apache.jena.query.ResultSet) QueryExecution(org.apache.jena.query.QueryExecution)

Example 7 with ResultSet

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

the class TestSolverTDB method solve_02.

@Test
public void solve_02() {
    ResultSet rs1 = exec("(bgp (:s :p :o2))", graph);
    ResultSet rs2 = results("empty");
    equals(rs1, rs2);
}
Also used : ResultSet(org.apache.jena.query.ResultSet) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb.ConfigTest)

Example 8 with ResultSet

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

the class TestSolverTDB method solve_04.

@Test
public void solve_04() {
    // Below everything.
    ResultSet rs1 = exec("(bgp (:a :p :a))", graph);
    ResultSet rs2 = results("empty");
    equals(rs1, rs2);
}
Also used : ResultSet(org.apache.jena.query.ResultSet) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb.ConfigTest)

Example 9 with ResultSet

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

the class TestMultipleEmbedded method multiple_04.

// Two servers, one dataset under two names.
@Test
public void multiple_04() {
    DatasetGraph dsg = dataset();
    int port1 = FusekiLib.choosePort();
    FusekiEmbeddedServer server1 = FusekiEmbeddedServer.create().setPort(port1).add("/ds1", dsg).build().start();
    Txn.executeWrite(dsg, () -> dsg.add(q1));
    int port2 = FusekiLib.choosePort();
    FusekiEmbeddedServer server2 = FusekiEmbeddedServer.create().setPort(port2).add("/ds2", dsg).build().start();
    Txn.executeWrite(dsg, () -> dsg.add(q2));
    query("http://localhost:" + port1 + "/ds1", "SELECT * {?s ?p ?o}", qExec -> {
        ResultSet rs = qExec.execSelect();
        int x = ResultSetFormatter.consume(rs);
        assertEquals(2, x);
    });
    query("http://localhost:" + port2 + "/ds2", "SELECT * {?s ?p ?o}", qExec -> {
        ResultSet rs = qExec.execSelect();
        int x = ResultSetFormatter.consume(rs);
        assertEquals(2, x);
    });
    server1.stop();
    server2.stop();
}
Also used : ResultSet(org.apache.jena.query.ResultSet) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 10 with ResultSet

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

the class TestEmbeddedFuseki method embedded_01.

// Test - build on default port. 
@Test
public void embedded_01() {
    DatasetGraph dsg = dataset();
    // Default port.
    int port = 3330;
    FusekiEmbeddedServer server = FusekiEmbeddedServer.create().add("/ds", dsg).build();
    assertTrue(server.getDataAccessPointRegistry().isRegistered("/ds"));
    server.start();
    query("http://localhost:" + port + "/ds/query", "SELECT * { ?s ?p ?o}", qExec -> {
        ResultSet rs = qExec.execSelect();
        assertFalse(rs.hasNext());
    });
    server.stop();
}
Also used : ResultSet(org.apache.jena.query.ResultSet) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

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