Search in sources :

Example 71 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestGraphDeltas method sparql_graph_delta_01.

/**
     * Tests graph deltas calculation with SPARQL
     */
@Test
public void sparql_graph_delta_01() {
    Model a = ModelFactory.createDefaultModel();
    Model b = ModelFactory.createDefaultModel();
    a.read(new StringReader(testData), null, "TTL");
    b.read(new StringReader(testData), null, "TTL");
    this.testDeltas(a, b, 0);
    this.testDeltas(b, a, 0);
}
Also used : Model(org.apache.jena.rdf.model.Model) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 72 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class TestGraphDeltas method sparql_graph_delta_02.

/**
     * Tests graph deltas calculate with SPARQL
     */
@Test
public void sparql_graph_delta_02() {
    Model a = ModelFactory.createDefaultModel();
    Model b = ModelFactory.createDefaultModel();
    a.read(new StringReader(testData), null, "TTL");
    b.read(new StringReader(testData2), null, "TTL");
    this.testDeltas(a, b, 0);
    this.testDeltas(b, a, 1);
}
Also used : Model(org.apache.jena.rdf.model.Model) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 73 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class GraphsTests method graph4.

@Test
public void graph4() {
    Dataset ds = getDataset();
    int x = query(queryString, ds.getNamedModel(Quad.unionGraph.getURI()));
    assertEquals(3, x);
    Model m = ds.getNamedModel(Quad.unionGraph.getURI());
    m.isIsomorphicWith(calcUnion);
}
Also used : Model(org.apache.jena.rdf.model.Model) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 74 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class GraphsTests method graph_api4.

@Test
public void graph_api4() {
    Dataset ds = getDataset();
    int x = api(ds.getNamedModel(Quad.unionGraph.getURI()));
    assertEquals(3, x);
    Model m = ds.getNamedModel(Quad.unionGraph.getURI());
    m.isIsomorphicWith(calcUnion);
}
Also used : Model(org.apache.jena.rdf.model.Model) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 75 with Model

use of org.apache.jena.rdf.model.Model in project jena by apache.

the class UpdateTest method datasetSame.

private boolean datasetSame(Dataset ds1, Dataset ds2, boolean verbose) {
    List<String> names1 = Iter.toList(ds1.listNames());
    List<String> names2 = Iter.toList(ds2.listNames());
    if (!names1.equals(names2)) {
        if (verbose) {
            System.out.println("Different named graphs");
            System.out.println("  " + names1);
            System.out.println("  " + names2);
        }
        return false;
    }
    if (!ds1.getDefaultModel().isIsomorphicWith(ds2.getDefaultModel())) {
        if (verbose)
            System.out.println("Default graphs differ");
        return false;
    }
    for (String gn : names1) {
        Model m1 = ds1.getNamedModel(gn);
        Model m2 = ds2.getNamedModel(gn);
        if (!m1.isIsomorphicWith(m2)) {
            if (verbose)
                System.out.println("Different on named graph " + gn);
            return false;
        }
    }
    return true;
}
Also used : Model(org.apache.jena.rdf.model.Model)

Aggregations

Model (org.apache.jena.rdf.model.Model)444 Test (org.junit.Test)177 BaseTest (org.apache.jena.atlas.junit.BaseTest)96 Resource (org.apache.jena.rdf.model.Resource)87 StringReader (java.io.StringReader)43 Dataset (org.apache.jena.query.Dataset)31 RDFReader (org.apache.jena.rdf.model.RDFReader)30 Property (org.apache.jena.rdf.model.Property)24 DatasetAccessor (org.apache.jena.query.DatasetAccessor)20 InfModel (org.apache.jena.rdf.model.InfModel)20 Node (org.apache.jena.graph.Node)19 Statement (org.apache.jena.rdf.model.Statement)18 RDFConnection (org.apache.jena.rdfconnection.RDFConnection)15 Reader (java.io.Reader)14 JsonString (org.apache.jena.atlas.json.JsonString)14 AbstractFusekiTest (org.apache.jena.fuseki.AbstractFusekiTest)14 FusekiTest (org.apache.jena.fuseki.FusekiTest)14 Graph (org.apache.jena.graph.Graph)14 JenaException (org.apache.jena.shared.JenaException)14 Triple (org.apache.jena.graph.Triple)13