Search in sources :

Example 21 with RDFReaderI

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

the class MoreTests method testIcu.

// JENA-1537
// Character encoding checks removed due to lack of support in JDK XML parser APIs.
// public void testLatin1() throws IOException {
// Model m = createMemModel();
// RDFReader rdr = m.getReader();
// InputStream r = new FileInputStream(
// "testing/arp/i18n/latin1.rdf");
// 
// rdr.setErrorHandler(this);
// expected = new int[] { WARN_NONCANONICAL_IANA_NAME };
// rdr.read(m, r, "http://example.org/");
// checkExpected();
// }
// JENA-1537
// Character encoding checks removed due to lack of support in JDK XML parser APIs.
// public void testARPMacRoman() throws IOException {
// Model m = createMemModel();
// RDFReader rdr = m.getReader();
// InputStream r = new FileInputStream(
// "testing/arp/i18n/macroman.rdf");
// 
// rdr.setErrorHandler(this);
// expected = new int[] { WARN_UNSUPPORTED_ENCODING, WARN_NON_IANA_ENCODING };
// expected[Charset.isSupported("MacRoman")?0:1]=0;
// //		 Only one of the warnings is expected, which depends on Java version
// 
// rdr.read(m, r, "http://example.org/");
// checkExpected();
// }
// public void testARPMacArabic() throws IOException {
// Model m = createMemModel();
// RDFReader rdr = m.getReader();
// InputStream r = new FileInputStream(
// "testing/arp/i18n/arabic-macarabic.rdf");
// 
// rdr.setErrorHandler(this);
// expected = new int[] { WARN_UNSUPPORTED_ENCODING, WARN_NON_IANA_ENCODING };
// expected[Charset.isSupported("MacArabic")?0:1]=0;
// //		 Only one of the warnings is expected, which depends on Java version
// rdr.read(m, r, "http://example.org/");
// checkExpected();
// }
// 
// 
// 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();
// }
// }
public void testIcu() throws IOException {
    // "\u0b87\u0ba8\u0bcd\u0ba4\u0bbf\u0baf\u0bbe"
    // Normalizer.  isNormalized(
    // "\u0bcd\u0ba4\u0bbf\u0baf\u0bbe"
    // ,Normalizer.NFC,0);
    Model m = createMemModel();
    RDFReaderI rdr = m.getReader();
    try (FileInputStream r = new FileInputStream("testing/arp/i18n/icubug.rdf")) {
        rdr.setErrorHandler(this);
        expected = new int[] { WARN_STRING_COMPOSING_CHAR };
        rdr.read(m, r, "http://example.org/");
    }
    checkExpected();
}
Also used : RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) Model(org.apache.jena.rdf.model.Model)

Example 22 with RDFReaderI

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

the class MoreTests method testIRIRules_2a.

public void testIRIRules_2a() {
    Model model = ModelFactory.createDefaultModel();
    RDFReaderI r = model.getReader("RDF/XML");
    r.setErrorHandler(this);
    expected = new int[] {};
    model.read(new StringReader(RDF_TEXT), "http://example/");
    checkExpected();
}
Also used : RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) Model(org.apache.jena.rdf.model.Model)

Example 23 with RDFReaderI

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

the class ExceptionTests method testDefaultPromotedWarning.

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

Example 24 with RDFReaderI

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

the class ExceptionTests method testDefaultDemotedFatal.

public void testDefaultDemotedFatal() {
    RDFDefaultErrorHandler.silent = true;
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReaderI rdr = m.getReader();
        rdr.setProperty("ERR_SAX_FATAL_ERROR", "EM_ERROR");
        rdr.read(m, "file:testing/arp/error-msgs/test06.rdf");
    } catch (JenaException e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        fail("Demoted.error error threw an exception");
    } 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 25 with RDFReaderI

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

the class ExceptionTests method testNonExceptionFatal.

public void testNonExceptionFatal() {
    try {
        Model m = ModelFactory.createDefaultModel();
        RDFReaderI 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) 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