Search in sources :

Example 1 with RDFReaderI

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

the class ExceptionTests method testExceptionError.

public void testExceptionError() {
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReaderI 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) RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) Model(org.apache.jena.rdf.model.Model)

Example 2 with RDFReaderI

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

the class ExceptionTests method testExceptionWarning.

public void testExceptionWarning() {
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReaderI 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) RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) Model(org.apache.jena.rdf.model.Model)

Example 3 with RDFReaderI

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

the class ExceptionTests method testDefaultPromotedError.

public void testDefaultPromotedError() {
    RDFDefaultErrorHandler.silent = true;
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReaderI rdr = m.getReader();
        rdr.setProperty("ERR_BAD_RDF_ATTRIBUTE", "EM_FATAL");
        rdr.read(m, "file:testing/wg/rdfms-abouteach/error002.rdf");
        fail("Promoted error did not throw exception");
    } catch (JenaException e) {
    // System.err.println(e.getMessage());
    } finally {
        RDFDefaultErrorHandler.silent = false;
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) Model(org.apache.jena.rdf.model.Model)

Example 4 with RDFReaderI

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

the class TestReaderEvents method testReaderEvent.

public void testReaderEvent(final String language, final String emptyModel) {
    final RecordingModelListener L = new RecordingModelListener();
    model.register(L);
    final RDFReaderI r = model.getReader(language);
    final StringReader stringReader = new StringReader(emptyModel);
    r.read(model, stringReader, "");
    L.assertHasStart(new Object[] { "someEvent", model, GraphEvents.startRead });
    L.assertHasEnd(new Object[] { "someEvent", model, GraphEvents.finishRead });
}
Also used : RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) StringReader(java.io.StringReader) RecordingModelListener(org.apache.jena.rdf.model.test.helpers.RecordingModelListener)

Example 5 with RDFReaderI

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

the class MoreTests method testBadBaseParamError.

public void testBadBaseParamError() throws IOException {
    Model m = createMemModel();
    RDFReaderI rdr = m.getReader();
    try (FileInputStream fin = new FileInputStream("testing/wg/rdfms-difference-between-ID-and-about/test1.rdf")) {
        rdr.setErrorHandler(this);
        expected = new int[] { WARN_MALFORMED_URI, WARN_MALFORMED_URI, // WARN_RELATIVE_URI, ERR_RESOLVING_AGAINST_MALFORMED_BASE};
        ERR_RESOLVING_AGAINST_MALFORMED_BASE };
        rdr.read(m, fin, "http://jjc^3.org/demo.mp3");
    }
    Model m1 = createMemModel();
    assertTrue("Bad base URI should produce no URIs in model.[" + m.toString() + "]", m.isIsomorphicWith(m1));
    checkExpected();
}
Also used : RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) Model(org.apache.jena.rdf.model.Model)

Aggregations

RDFReaderI (org.apache.jena.rdf.model.RDFReaderI)28 Model (org.apache.jena.rdf.model.Model)25 JenaException (org.apache.jena.shared.JenaException)7 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 StringReader (java.io.StringReader)1 IRIFactory (org.apache.jena.iri.IRIFactory)1 RDFWriterI (org.apache.jena.rdf.model.RDFWriterI)1 RecordingModelListener (org.apache.jena.rdf.model.test.helpers.RecordingModelListener)1 RDFEHArray (org.apache.jena.rdfxml.xmlinput.SAX2RDFTest.RDFEHArray)1 BadURIException (org.apache.jena.shared.BadURIException)1 InvalidPropertyURIException (org.apache.jena.shared.InvalidPropertyURIException)1 InputSource (org.xml.sax.InputSource)1 SAXParseException (org.xml.sax.SAXParseException)1 XMLReader (org.xml.sax.XMLReader)1