Search in sources :

Example 16 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class WGTestSuite method loadRDF.

private Model loadRDF(final TestInputStreamFactory fact, final String file) {
    Model m = null;
    String base = fact.getBase().toString();
    if (!base.endsWith("/"))
        base = base + "/";
    try (InputStream in = fact.fullyOpen(file)) {
        if (in == null)
            return null;
        m = loadRDF(new InFactoryX() {

            @Override
            public InputStream open() throws IOException {
                return fact.fullyOpen(file);
            }
        }, null, base + file);
    } catch (JenaException e) {
        //	System.out.println(e.getMessage());
        throw e;
    } catch (Exception e) {
        //	e.printStackTrace();
        if (file.equals("Manifest.rdf")) {
            System.err.println("Failed to open Manifest.rdf");
            e.printStackTrace();
        }
    }
    return m;
}
Also used : JenaException(org.apache.jena.shared.JenaException) InputStream(java.io.InputStream) BrokenException(org.apache.jena.shared.BrokenException) ParseException(org.apache.jena.rdfxml.xmlinput.ParseException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) JenaException(org.apache.jena.shared.JenaException)

Example 17 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class ExceptionTests method testDefaultWarning.

public void testDefaultWarning() {
    // W108
    RDFDefaultErrorHandler.silent = true;
    try {
        Model m = ModelFactory.createDefaultModel();
        m.read("file:testing/arp/qname-in-ID/bug74_0.rdf");
    } catch (JenaException e) {
        fail("Warning threw exception");
    } finally {
        RDFDefaultErrorHandler.silent = false;
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) Model(org.apache.jena.rdf.model.Model)

Example 18 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class ExceptionTests method testExceptionWarning.

public void testExceptionWarning() {
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReader rdr = m.getReader();
        rdr.setErrorHandler(this);
        rdr.read(m, "file:testing/arp/qname-in-ID/bug74_0.rdf");
        fail("Warning did not throw exception with non-standard handler");
    } catch (JenaException e) {
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 19 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class ExceptionTests method testExceptionError.

public void testExceptionError() {
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReader rdr = m.getReader();
        rdr.setErrorHandler(this);
        rdr.read(m, "file:testing/wg/rdfms-abouteach/error002.rdf");
        fail("Error did not throw exception with non-standard handler");
    } catch (JenaException e) {
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 20 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class ExceptionTests method testDefaultError.

public void testDefaultError() {
    // E206
    RDFDefaultErrorHandler.silent = true;
    try {
        Model m = ModelFactory.createDefaultModel();
        m.read("file:testing/wg/rdfms-abouteach/error002.rdf");
    } catch (JenaException e) {
        fail("Error threw exception");
    } finally {
        RDFDefaultErrorHandler.silent = false;
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) Model(org.apache.jena.rdf.model.Model)

Aggregations

JenaException (org.apache.jena.shared.JenaException)70 Model (org.apache.jena.rdf.model.Model)12 RDFReader (org.apache.jena.rdf.model.RDFReader)8 IOException (java.io.IOException)7 QueryException (org.apache.jena.query.QueryException)5 QueryParseException (org.apache.jena.query.QueryParseException)5 java.io (java.io)4 InputStream (java.io.InputStream)4 Reader (java.io.Reader)4 StringReader (java.io.StringReader)4 Graph (org.apache.jena.graph.Graph)4 ServletOutputStream (javax.servlet.ServletOutputStream)3 CmdException (jena.cmd.CmdException)3 AmbiguousSpecificTypeException (org.apache.jena.assembler.exceptions.AmbiguousSpecificTypeException)3 MediaType (org.apache.jena.atlas.web.MediaType)3 Triple (org.apache.jena.graph.Triple)3 BadDescriptionMultipleRootsException (org.apache.jena.shared.BadDescriptionMultipleRootsException)3 BadDescriptionNoRootException (org.apache.jena.shared.BadDescriptionNoRootException)3 ARQParser (org.apache.jena.sparql.lang.arq.ARQParser)3 FileNotFoundException (java.io.FileNotFoundException)2