Search in sources :

Example 36 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class TestSolverTDB method solve_02.

@Test
public void solve_02() {
    RowSet rs1 = exec("(bgp (:s :p :o2))");
    RowSet rs2 = results("empty");
    equals(rs1, rs2);
}
Also used : RowSet(org.apache.jena.sparql.exec.RowSet) ConfigTest(org.apache.jena.tdb2.ConfigTest) Test(org.junit.Test)

Example 37 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class TestSolverTDB method solve_01.

@Test
public void solve_01() {
    RowSet rs1 = exec("(bgp (:s :p :o))");
    RowSet rs2 = results("unit");
    equals(rs1, rs2);
}
Also used : RowSet(org.apache.jena.sparql.exec.RowSet) ConfigTest(org.apache.jena.tdb2.ConfigTest) Test(org.junit.Test)

Example 38 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class TestSolverTDB method solve_05.

@Test
public void solve_05() {
    RowSet rs1 = exec("(project (?s ?y) (bgp (?s :p ?z) (?z :q ?y)))");
    RowSet rs2 = results("(row (?s :s) (?y :y))");
    equals(rs1, rs2);
}
Also used : RowSet(org.apache.jena.sparql.exec.RowSet) ConfigTest(org.apache.jena.tdb2.ConfigTest) Test(org.junit.Test)

Example 39 with RowSet

use of org.apache.jena.sparql.exec.RowSet 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 = WebLib.choosePort();
    FusekiServer server1 = FusekiServer.create().port(port1).add("/ds1", dsg).build().start();
    Txn.executeWrite(dsg, () -> dsg.add(q1));
    int port2 = WebLib.choosePort();
    FusekiServer server2 = FusekiServer.create().port(port2).add("/ds2", dsg).build().start();
    Txn.executeWrite(dsg, () -> dsg.add(q2));
    query("http://localhost:" + port1 + "/ds1", "SELECT * {?s ?p ?o}", qExec -> {
        RowSet rs = qExec.select();
        long x = Iter.count(rs);
        assertEquals(2, x);
    });
    query("http://localhost:" + port2 + "/ds2", "SELECT * {?s ?p ?o}", qExec -> {
        RowSet rs = qExec.select();
        long x = Iter.count(rs);
        assertEquals(2, x);
    });
    server1.stop();
    server2.stop();
}
Also used : RowSet(org.apache.jena.sparql.exec.RowSet) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 40 with RowSet

use of org.apache.jena.sparql.exec.RowSet in project jena by apache.

the class TestMultipleEmbedded method multiple_03.

// Two servers, two datasets.
@Test
public void multiple_03() {
    DatasetGraph dsg1 = dataset();
    DatasetGraph dsg2 = dataset();
    // Same name.
    int port1 = WebLib.choosePort();
    FusekiServer server1 = FusekiServer.create().port(port1).add("/ds", dsg1).build().start();
    Txn.executeWrite(dsg1, () -> dsg1.add(q1));
    int port2 = WebLib.choosePort();
    FusekiServer server2 = FusekiServer.create().port(port2).add("/ds", dsg2).build().start();
    Txn.executeWrite(dsg2, () -> dsg2.add(q2));
    query("http://localhost:" + port1 + "/ds/", "SELECT * {?s ?p 1}", qExec -> {
        RowSet rs = qExec.select();
        long x = Iter.count(rs);
        assertEquals(1, x);
    });
    query("http://localhost:" + port2 + "/ds/", "SELECT * {?s ?p 1}", qExec -> {
        RowSet rs = qExec.select();
        long x = Iter.count(rs);
        assertEquals(0, x);
    });
    server1.stop();
    // server2 still running
    query("http://localhost:" + port2 + "/ds/", "SELECT * {?s ?p 2}", qExec -> {
        RowSet rs = qExec.select();
        long x = Iter.count(rs);
        assertEquals(1, x);
    });
    server2.stop();
}
Also used : RowSet(org.apache.jena.sparql.exec.RowSet) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Aggregations

RowSet (org.apache.jena.sparql.exec.RowSet)43 Test (org.junit.Test)36 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)12 EnvTest (org.apache.jena.test.conn.EnvTest)10 QueryExec (org.apache.jena.sparql.exec.QueryExec)9 RDFLink (org.apache.jena.rdflink.RDFLink)7 ConfigTest (org.apache.jena.tdb.ConfigTest)7 ConfigTest (org.apache.jena.tdb2.ConfigTest)7 Binding (org.apache.jena.sparql.engine.binding.Binding)6 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 HttpRequestModifier (org.apache.jena.http.sys.HttpRequestModifier)2 ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)2 Quad (org.apache.jena.sparql.core.Quad)2 Var (org.apache.jena.sparql.core.Var)2 QueryExecResult (org.apache.jena.sparql.exec.QueryExecResult)2 HttpClient (java.net.http.HttpClient)1 CSVParser (org.apache.jena.atlas.csv.CSVParser)1 HttpException (org.apache.jena.atlas.web.HttpException)1