Search in sources :

Example 1 with DatasetGraph

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

the class TestTriXReader method trix_direct.

@Test
public void trix_direct() {
    ReaderRIOT r = new ReaderTriX(RiotLib.dftProfile(), ErrorHandlerFactory.errorHandlerNoWarnings);
    InputStream in = IO.openFile(fInput);
    DatasetGraph dsg = DatasetGraphFactory.create();
    //StreamRDF stream = StreamRDFLib.writer(System.out) ;
    StreamRDF stream = StreamRDFLib.dataset(dsg);
    stream.start();
    r.read(in, null, null, stream, null);
    stream.finish();
    if (fExpected != null) {
        DatasetGraph dsg2 = RDFDataMgr.loadDatasetGraph(fExpected);
        boolean b = IsoMatcher.isomorphic(dsg, dsg2);
        if (!b) {
            Assert.fail("Not isomorphic");
        }
    }
}
Also used : ReaderRIOT(org.apache.jena.riot.ReaderRIOT) InputStream(java.io.InputStream) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 2 with DatasetGraph

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

the class TestLangTrig method trig_11.

@Test
public void trig_11() {
    DatasetGraph dsg = parse("@prefix ex:  <http://example/> .", "{ ex:s ex:p 123 }");
    assertEquals(1, dsg.getDefaultGraph().size());
    Triple t = dsg.getDefaultGraph().find(null, null, null).next();
    Triple t2 = SSE.parseTriple("(<http://example/s> <http://example/p> 123)");
}
Also used : Triple(org.apache.jena.graph.Triple) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 3 with DatasetGraph

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

the class TestLangTrig method trig_10.

// Need to check we get resolved URIs.
//{ parse("{ <x> <p> <q> }") ; }
@Test
public //{ parse("{ <x> <p> <q> }") ; }
void trig_10() {
    DatasetGraph dsg = parse("{ <x> <p> <q> }");
    assertEquals(1, dsg.getDefaultGraph().size());
    Triple t = dsg.getDefaultGraph().find(null, null, null).next();
    Triple t2 = SSE.parseTriple("(<http://base/x> <http://base/p> <http://base/q>)");
    assertEquals(t2, t);
}
Also used : Triple(org.apache.jena.graph.Triple) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 4 with DatasetGraph

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

the class AbstractTestUpdateGraph method testUpdateScript6.

@Test
public void testUpdateScript6() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    script(gStore, "data-3.ru");
    assertTrue(graphContains(gStore.getGraph(graphIRI), new Triple(s, p, NodeFactoryExtra.parseNode("123"))));
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 5 with DatasetGraph

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

the class AbstractTestUpdateGraphMgt method testCreateDrop2.

@Test
public void testCreateDrop2() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    Update u = new UpdateCreate(graphIRI);
    UpdateAction.execute(u, gStore);
    u = new UpdateCreate(graphIRI, true);
    UpdateAction.execute(u, gStore);
    // JENA-1068
    //        assertTrue(gStore.containsGraph(graphIRI)) ;
    assertTrue(graphEmpty(gStore.getGraph(graphIRI)));
    u = new UpdateDrop(graphIRI);
    UpdateAction.execute(u, gStore);
    assertFalse(gStore.containsGraph(graphIRI));
    u = new UpdateDrop(graphIRI, true);
    UpdateAction.execute(u, gStore);
}
Also used : UpdateCreate(org.apache.jena.sparql.modify.request.UpdateCreate) Update(org.apache.jena.update.Update) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) UpdateDrop(org.apache.jena.sparql.modify.request.UpdateDrop) Test(org.junit.Test)

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