Search in sources :

Example 31 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class TestAPI method testARQConstructQuad_Prefix.

// Allow duplicated template quads in execConstructQuads()
@Test
public void testARQConstructQuad_Prefix() {
    String queryString = "PREFIX :   <http://example/ns#> CONSTRUCT { GRAPH :g1 { ?s :p ?o} } WHERE { ?s ?p ?o }";
    Query q = QueryFactory.create(queryString, Syntax.syntaxARQ);
    QueryExecution qExec = QueryExecutionFactory.create(q, d);
    Iterator<Quad> quads = qExec.execConstructQuads();
    DatasetGraph result = DatasetGraphFactory.create();
    long count = 0;
    while (quads.hasNext()) {
        count++;
        Quad qd = quads.next();
        result.add(qd);
    }
    DatasetGraph expected = DatasetGraphFactory.create();
    expected.add(g1.asNode(), s.asNode(), p.asNode(), o.asNode());
    assertEquals(1, count);
    assertTrue(IsoMatcher.isomorphic(expected, result));
}
Also used : Quad(org.apache.jena.sparql.core.Quad) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 32 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractDatasetGraphFind method create.

/**
     * Create the dataset to test loaded with the supplied data - this dataset need not be mutable.
     * Either supply {@link #create()} or override this method.  
     */
protected DatasetGraph create(Collection<Quad> data) {
    DatasetGraph dsg = create();
    add(dsg, data);
    return dsg;
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 33 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractTestTransPromote method run_07.

// Async writer after promotion.
private void run_07(boolean readCommitted) {
    Assume.assumeTrue(!readCommitted || supportsReadCommitted());
    setReadCommitted(readCommitted);
    DatasetGraph dsg = create();
    // Start long running reader.
    ThreadAction tt = ThreadTxn.threadTxnRead(dsg, () -> {
        long x = Iter.count(dsg.find());
        if (x != 0)
            throw new RuntimeException();
    });
    // Start R->W here
    dsg.begin(ReadWrite.READ);
    dsg.add(q1);
    dsg.add(q2);
    dsg.commit();
    dsg.end();
    tt.run();
}
Also used : ThreadAction(org.apache.jena.system.ThreadAction) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 34 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractTestTransPromote method run_04.

private void run_04(boolean readCommitted) {
    Assume.assumeTrue(!readCommitted || supportsReadCommitted());
    setReadCommitted(readCommitted);
    DatasetGraph dsg = create();
    dsg.begin(ReadWrite.WRITE);
    dsg.abort();
    dsg.end();
    dsg.begin(ReadWrite.READ);
    dsg.add(q1);
    dsg.commit();
    dsg.end();
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 35 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractTestTransPromote method run_02.

// Previous transaction then READ-add
private void run_02(boolean readCommitted) {
    Assume.assumeTrue(!readCommitted || supportsReadCommitted());
    setReadCommitted(readCommitted);
    DatasetGraph dsg = create();
    dsg.begin(ReadWrite.READ);
    dsg.end();
    dsg.begin(ReadWrite.READ);
    dsg.add(q1);
    dsg.commit();
    dsg.end();
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Aggregations

DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)222 Test (org.junit.Test)132 BaseTest (org.apache.jena.atlas.junit.BaseTest)59 Quad (org.apache.jena.sparql.core.Quad)47 Node (org.apache.jena.graph.Node)29 Graph (org.apache.jena.graph.Graph)18 StoreConnection (org.apache.jena.tdb.StoreConnection)17 DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)15 Model (org.apache.jena.rdf.model.Model)10 IOException (java.io.IOException)7 Triple (org.apache.jena.graph.Triple)7 Dataset (org.apache.jena.query.Dataset)7 StreamRDF (org.apache.jena.riot.system.StreamRDF)7 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)5 ResultSet (org.apache.jena.query.ResultSet)5 JsonLDWriteContext (org.apache.jena.riot.JsonLDWriteContext)5 Element (org.apache.jena.sparql.syntax.Element)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 RiotException (org.apache.jena.riot.RiotException)4 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)4