Search in sources :

Example 26 with RDFConnection

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

the class AbstractTestRDFConnection method query_select_02.

@Test
public void query_select_02() {
    AtomicInteger counter = new AtomicInteger(0);
    try (RDFConnection conn = connection()) {
        conn.loadDataset(DIR + "data.trig");
        conn.querySelect("SELECT * { ?s ?p ?o}", (r) -> counter.incrementAndGet());
        assertEquals(2, counter.get());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 27 with RDFConnection

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

the class AbstractTestRDFConnection method named_graph_put_1.

@Test
public void named_graph_put_1() {
    try (RDFConnection conn = connection()) {
        conn.put(graphName, model1);
        Dataset ds1 = conn.fetchDataset();
        Model m0 = conn.fetch(graphName);
        assertTrue("Models not isomorphic", isomorphic(model1, ds1.getNamedModel(graphName)));
        Model m = conn.fetch(graphName);
        assertTrue("Models not isomorphic", isomorphic(model1, m));
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 28 with RDFConnection

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

the class AbstractTestRDFConnection method named_graph_post_2.

@Test
public void named_graph_post_2() {
    try (RDFConnection conn = connection()) {
        conn.load(graphName, model1);
        conn.load(graphName, model2);
        Model m = conn.fetch(graphName);
        Model m0 = ModelFactory.createUnion(model2, model1);
        assertTrue("Models are not isomorphic", isomorphic(m0, m));
    }
}
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 29 with RDFConnection

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

the class AbstractTestRDFConnection method query_construct_02.

@Test
public void query_construct_02() {
    try (RDFConnection conn = connection()) {
        conn.loadDataset(DIR + "data.trig");
        Model m = conn.queryConstruct("CONSTRUCT WHERE { ?s ?p ?o }");
        assertEquals(2, m.size());
    }
}
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