Search in sources :

Example 16 with Model

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

the class QueryTest method createDataset.

private static Dataset createDataset(List<String> defaultGraphURIs, List<String> namedGraphURIs) {
    // Allow "qt:data" to be quads in defaultGraphURIs.
    Dataset ds = DatasetFactory.createGeneral();
    if (defaultGraphURIs != null) {
        for (String sourceURI : defaultGraphURIs) {
            RDFDataMgr.read(ds, sourceURI);
        }
    }
    if (namedGraphURIs != null) {
        for (String sourceURI : namedGraphURIs) {
            String absSourceURI = IRIResolver.resolveString(sourceURI);
            Model m = ds.getNamedModel(absSourceURI);
            RDFDataMgr.read(m, sourceURI);
        }
    }
    return ds;
}
Also used : Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model)

Example 17 with Model

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

the class QueryTest method compareGraphResults.

private void compareGraphResults(Model resultsActual, Query query) {
    if (results != null) {
        try {
            if (!results.isGraph())
                fail("Expected results are not a graph: " + testItem.getName());
            Model resultsExpected = results.getModel();
            if (!resultsExpected.isIsomorphicWith(resultsActual)) {
                printFailedModelTest(query, resultsExpected, resultsActual);
                fail("Results do not match: " + testItem.getName());
            }
        } catch (Exception ex) {
            String typeName = (query.isConstructType() ? "construct" : "describe");
            fail("Exception in result testing (" + typeName + "): " + ex);
        }
    }
}
Also used : Model(org.apache.jena.rdf.model.Model) QueryException(org.apache.jena.query.QueryException) IOException(java.io.IOException) JenaException(org.apache.jena.shared.JenaException)

Example 18 with Model

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

the class QueryTest method runTestDescribe.

void runTestDescribe(Query query, QueryExecution qe) {
    Model resultsActual = qe.execDescribe();
    compareGraphResults(resultsActual, query);
}
Also used : Model(org.apache.jena.rdf.model.Model)

Example 19 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)

Example 20 with Model

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

the class rdflangtest method oneManifestEarl.

static void oneManifestEarl(String testManifest) {
    EarlReport report = new EarlReport(systemURI, name, version, homepage);
    FactoryTestRiot.report = report;
    TestSuite suite = FactoryTestRiot.make(testManifest, null, null);
    SimpleTestRunner.runSilent(suite);
    Model model = report.getModel();
    model.setNsPrefix("rdft", VocabLangRDF.getURI());
    model.setNsPrefix("turtletest", "http://www.w3.org/2013/TurtleTests/manifest.ttl#");
    insertMetaOld(report);
    RDFDataMgr.write(System.out, model, Lang.TURTLE);
}
Also used : TestSuite(junit.framework.TestSuite) Model(org.apache.jena.rdf.model.Model) EarlReport(org.apache.jena.sparql.junit.EarlReport)

Aggregations

Model (org.apache.jena.rdf.model.Model)920 Test (org.junit.Test)338 Dataset (org.apache.jena.query.Dataset)196 Resource (org.apache.jena.rdf.model.Resource)178 StringReader (java.io.StringReader)66 Statement (org.apache.jena.rdf.model.Statement)54 Property (org.apache.jena.rdf.model.Property)45 InfModel (org.apache.jena.rdf.model.InfModel)41 Ignore (org.junit.Ignore)38 RDFNode (org.apache.jena.rdf.model.RDFNode)35 Node (org.apache.jena.graph.Node)34 URI (java.net.URI)33 Graph (org.apache.jena.graph.Graph)33 QueryExecution (org.apache.jena.query.QueryExecution)31 Reader (java.io.Reader)30 StmtIterator (org.apache.jena.rdf.model.StmtIterator)27 RDFReaderI (org.apache.jena.rdf.model.RDFReaderI)25 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)24 RdfUtils (won.protocol.util.RdfUtils)24 InputStream (java.io.InputStream)22