Search in sources :

Example 26 with RDFReader

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

the class ExceptionTests method testDefaultPromotedWarning.

public void testDefaultPromotedWarning() {
    RDFDefaultErrorHandler.silent = true;
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReader rdr = m.getReader();
        rdr.setProperty("WARN_BAD_NAME", "EM_FATAL");
        rdr.read(m, "file:testing/arp/qname-in-ID/bug74_0.rdf");
        fail("Promoted warning did not throw exception");
    } catch (JenaException e) {
    } finally {
        RDFDefaultErrorHandler.silent = false;
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 27 with RDFReader

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

the class ExceptionTests method testNonExceptionFatal.

public void testNonExceptionFatal() {
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReader rdr = m.getReader();
        rdr.setErrorHandler(this);
        rdr.read(m, "file:testing/arp/error-msgs/test06.rdf");
    } catch (JenaException e) {
        fail("Fatal error threw an exception with non-exception handler");
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 28 with RDFReader

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

the class MoreTests method testNullBaseParamOK.

public void testNullBaseParamOK() throws IOException {
    Model m = createMemModel();
    Model m1 = createMemModel();
    RDFReader rdr = m.getReader();
    try (FileInputStream fin = new FileInputStream("testing/wg/rdfms-identity-anon-resources/test001.rdf")) {
        rdr.setErrorHandler(this);
        expected = new int[] {};
        rdr.read(m, fin, "http://example.org/");
    }
    try (FileInputStream fin = new FileInputStream("testing/wg/rdfms-identity-anon-resources/test001.rdf")) {
        rdr.read(m1, fin, null);
    }
    assertTrue("Base URI should have no effect.", m.isIsomorphicWith(m1));
    checkExpected();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 29 with RDFReader

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

the class MoreTests method testIRIRules_4.

public void testIRIRules_4() {
    Model model = ModelFactory.createDefaultModel();
    RDFReader r = model.getReader("RDF/XML");
    r.setProperty("iri-rules", "strict");
    r.setProperty("WARN_MALFORMED_URI", ARPErrorNumbers.EM_ERROR);
    r.setErrorHandler(this);
    // Errors actually continue.
    expected = new int[] { WARN_MALFORMED_URI, WARN_MALFORMED_URI };
    r.read(model, new StringReader(RDF_TEXT), "http://example/");
    checkExpected();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 30 with RDFReader

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

the class MoreTests method testEncodingMismatch1.

public void testEncodingMismatch1() throws IOException {
    Model m = createMemModel();
    RDFReader rdr = m.getReader();
    try (FileReader r = new FileReader("testing/wg/rdfms-syntax-incomplete/test001.rdf")) {
        if (r.getEncoding().startsWith("UTF")) {
            //logger.warn("Encoding mismatch tests not executed on platform with default UTF encoding.");
            r.close();
            return;
        }
        rdr.setErrorHandler(this);
        expected = new int[] { WARN_ENCODING_MISMATCH };
        rdr.read(m, r, "http://example.org/");
        //System.err.println(m.size() + " triples read.");
        checkExpected();
    }
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Aggregations

RDFReader (org.apache.jena.rdf.model.RDFReader)34 Model (org.apache.jena.rdf.model.Model)30 JenaException (org.apache.jena.shared.JenaException)8 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 SAX2Model (org.apache.jena.rdfxml.xmlinput.SAX2Model)2 StringReader (java.io.StringReader)1 IRIFactory (org.apache.jena.iri.IRIFactory)1 TurtleParseException (org.apache.jena.n3.turtle.TurtleParseException)1 TurtleReader (org.apache.jena.n3.turtle.TurtleReader)1 RDFWriter (org.apache.jena.rdf.model.RDFWriter)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 ConfigException (org.apache.jena.shared.ConfigException)1 InvalidPropertyURIException (org.apache.jena.shared.InvalidPropertyURIException)1 NoReaderForLangException (org.apache.jena.shared.NoReaderForLangException)1 SAXParser (org.apache.xerces.parsers.SAXParser)1 InputSource (org.xml.sax.InputSource)1 SAXParseException (org.xml.sax.SAXParseException)1