Search in sources :

Example 31 with RiotException

use of org.apache.jena.riot.RiotException in project jena by apache.

the class UnitTestBadSyntax method run4.

private void run4() {
    Dataset ds = DatasetFactory.createGeneral();
    try {
        RDFDataMgr.read(ds, uri, uri, lang);
    } catch (RiotException ex) {
        return;
    } catch (RuntimeException ex) {
        ex.printStackTrace(System.err);
        fail("Unexpected exception");
    }
    fail("Bad syntax test succeed in parsing the file");
}
Also used : RiotException(org.apache.jena.riot.RiotException) Dataset(org.apache.jena.query.Dataset)

Example 32 with RiotException

use of org.apache.jena.riot.RiotException in project jena by apache.

the class UnitTestEval method run4.

private void run4() {
    DatasetGraph dsg = DatasetGraphFactory.create();
    try {
        if (baseIRI != null)
            RDFDataMgr.read(dsg, input, baseIRI, lang);
        else
            RDFDataMgr.read(dsg, input, lang);
        Lang outLang = RDFLanguages.filenameToLang(output, Lang.NQUADS);
        DatasetGraph results = DatasetGraphFactory.create();
        try {
            RDFDataMgr.read(results, output, outLang);
        } catch (RiotException ex) {
            fail("Failed to read results: " + ex.getMessage());
        }
        boolean b = isomorphic(dsg, results);
        if (!b) {
            System.out.println("**** Test: " + getName());
            System.out.println("---- Parsed");
            RDFDataMgr.write(System.out, dsg, Lang.TRIG);
            System.out.println("---- Expected");
            RDFDataMgr.write(System.out, results, Lang.TRIG);
            System.out.println("--------");
        }
        assertTrue("Datasets not isomorphic", b);
    } catch (RiotException ex) {
        // Catch and rethrow - debugging.
        throw ex;
    } catch (RuntimeException ex) {
        ex.printStackTrace(System.err);
        throw ex;
    }
}
Also used : RiotException(org.apache.jena.riot.RiotException) Lang(org.apache.jena.riot.Lang) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Example 33 with RiotException

use of org.apache.jena.riot.RiotException in project jena by apache.

the class UnitTestEval method run3.

// Triples test.
private void run3() {
    Model model = ModelFactory.createDefaultModel();
    try {
        if (baseIRI != null)
            RDFDataMgr.read(model, input, baseIRI, lang);
        else
            RDFDataMgr.read(model, input, lang);
        Lang outLang = RDFLanguages.filenameToLang(output, Lang.NQUADS);
        Model results = ModelFactory.createDefaultModel();
        try {
            RDFDataMgr.read(results, output, outLang);
        } catch (RiotException ex) {
            fail("Failed to read results: " + ex.getMessage());
        }
        boolean b = model.isIsomorphicWith(results);
        if (!b) {
            //model.isIsomorphicWith(results) ;
            System.out.println("---- Parsed");
            model.write(System.out, "TTL");
            System.out.println("---- Expected");
            results.write(System.out, "TTL");
            System.out.println("--------");
        }
        assertTrue("Models not isomorphic", b);
    } catch (RiotException ex) {
        // Catch and rethrow - debugging.
        throw ex;
    } catch (RuntimeException ex) {
        ex.printStackTrace(System.err);
        throw ex;
    }
}
Also used : RiotException(org.apache.jena.riot.RiotException) Model(org.apache.jena.rdf.model.Model) Lang(org.apache.jena.riot.Lang)

Aggregations

RiotException (org.apache.jena.riot.RiotException)33 Node (org.apache.jena.graph.Node)10 IOException (java.io.IOException)7 StreamRDF (org.apache.jena.riot.system.StreamRDF)7 Graph (org.apache.jena.graph.Graph)4 Model (org.apache.jena.rdf.model.Model)4 Lang (org.apache.jena.riot.Lang)4 Token (org.apache.jena.riot.tokens.Token)4 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)4 Dataset (org.apache.jena.query.Dataset)3 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)2 IRI (org.apache.jena.iri.IRI)2 Tokenizer (org.apache.jena.riot.tokens.Tokenizer)2 Var (org.apache.jena.sparql.core.Var)2 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 JsonLdError (com.github.jsonldjava.core.JsonLdError)1 RDFDataset (com.github.jsonldjava.core.RDFDataset)1 BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1