Search in sources :

Example 1 with RDFConnection

use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.

the class AbstractTestRDFConnection method transaction_commit_read_01.

// Not all Transactional support abort.
@Test
public void transaction_commit_read_01() {
    String testDataFile = DIR + "data.trig";
    try (RDFConnection conn = connection()) {
        conn.begin(ReadWrite.WRITE);
        conn.loadDataset(dataset);
        conn.commit();
        conn.end();
        conn.begin(ReadWrite.READ);
        Model m = conn.fetch();
        assertTrue(isomorphic(m, dataset.getDefaultModel()));
        conn.end();
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 2 with RDFConnection

use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.

the class RDFConnectionExample3 method main.

public static void main(String... args) {
    Query query = QueryFactory.create("SELECT * { <http://example.org/book/book1> ?p ?o }");
    String queryService = "http://sparql.org/books/query";
    // Query service, no update, no graph store protocol.
    try (RDFConnection conn = RDFConnectionFactory.connect(queryService, null, null)) {
        conn.queryResultSet(query, ResultSetFormatter::out);
    }
}
Also used : ResultSetFormatter(org.apache.jena.query.ResultSetFormatter) Query(org.apache.jena.query.Query) RDFConnection(org.apache.jena.rdfconnection.RDFConnection)

Example 3 with RDFConnection

use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.

the class AbstractTestRDFConnection method graph_post_1.

@Test
public void graph_post_1() {
    try (RDFConnection conn = connection()) {
        conn.load(model1);
        Model m = conn.fetch();
        assertTrue("Models not isomorphic", isomorphic(m, model1));
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 4 with RDFConnection

use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.

the class AbstractTestRDFConnection method dataset_put_2.

@Test
public void dataset_put_2() {
    try (RDFConnection conn = connection()) {
        conn.putDataset(dataset);
        conn.putDataset(dataset2);
        Dataset ds1 = conn.fetchDataset();
        assertTrue("Datasets not isomorphic", isomorphic(dataset2, ds1));
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Dataset(org.apache.jena.query.Dataset) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 5 with RDFConnection

use of org.apache.jena.rdfconnection.RDFConnection in project jena by apache.

the class AbstractTestRDFConnection method named_graph_post_1.

@Test
public void named_graph_post_1() {
    try (RDFConnection conn = connection()) {
        conn.load(graphName, model1);
        Model m = conn.fetch(graphName);
        assertTrue("Models not isomorphic", isomorphic(m, model1));
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Aggregations

RDFConnection (org.apache.jena.rdfconnection.RDFConnection)29 BaseTest (org.apache.jena.atlas.junit.BaseTest)25 Test (org.junit.Test)25 Model (org.apache.jena.rdf.model.Model)16 Dataset (org.apache.jena.query.Dataset)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Iter (org.apache.jena.atlas.iterator.Iter)1 StrUtils (org.apache.jena.atlas.lib.StrUtils)1 DatasetFactory (org.apache.jena.query.DatasetFactory)1 Query (org.apache.jena.query.Query)1 ReadWrite (org.apache.jena.query.ReadWrite)1 ResultSetFormatter (org.apache.jena.query.ResultSetFormatter)1 ModelFactory (org.apache.jena.rdf.model.ModelFactory)1 RDFDataMgr (org.apache.jena.riot.RDFDataMgr)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1 SSE (org.apache.jena.sparql.sse.SSE)1 IsoMatcher (org.apache.jena.sparql.util.IsoMatcher)1 Txn (org.apache.jena.system.Txn)1 Assume (org.junit.Assume)1