use of org.apache.jena.rdf.model.RDFReader in project jena by apache.
the class SAX2RDFTest method runTest.
@Override
public void runTest() throws Exception {
//System.err.println(base+" + "+this.file);
Model m = ModelFactory.createDefaultModel();
Model m2 = ModelFactory.createDefaultModel();
RDFEHArray eh = new RDFEHArray();
try (InputStream in = new FileInputStream(file)) {
RDFReader w = m.getReader();
w.setErrorHandler(eh);
w.read(m, in, base);
}
RDFEHArray eh2 = new RDFEHArray();
try (InputStream in = new FileInputStream(file)) {
/*
* w = m.getReader(); w.setErrorHandler(eh2); w.read(m2,in,base);
* in.close();
*/
loadXMLModel(m2, in, eh2);
}
/*
* System.out.println("Normal:"); m.write(System.out,"N-TRIPLE");
*
* System.out.println("New:"); m2.write(System.out,"N-TRIPLE");
*/
if (eh.v.size() == 0)
assertTrue("Not isomorphic", m.isIsomorphicWith(m2));
if (eh.v.size() != eh2.v.size()) {
for (int i = 0; i < eh.v.size(); i++) System.err.println(eh.v.get(i));
System.err.println("---");
for (int i = 0; i < eh2.v.size(); i++) System.err.println(eh2.v.get(i));
}
assertEquals("Different number of errors", eh.v.size(), eh2.v.size());
Object[] a = eh.v.toArray();
Object[] a2 = eh2.v.toArray();
Arrays.sort(a);
Arrays.sort(a2);
for (int i = 0; i < eh.v.size(); i++) {
assertEquals("Error " + i + " different.", a[i], a2[i]);
}
}
use of org.apache.jena.rdf.model.RDFReader in project jena by apache.
the class MoreTests method testIcu.
public void testIcu() throws IOException {
// "இந்தியா"
// Normalizer. isNormalized(
// "்தியா"
// ,Normalizer.NFC,0);
Model m = createMemModel();
RDFReader 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();
}
use of org.apache.jena.rdf.model.RDFReader in project jena by apache.
the class MoreTests method subTestEncodingMismatch2.
private void subTestEncodingMismatch2(InputStreamReader r) {
if (r.getEncoding().startsWith("UTF")) {
// see above for warning message.
return;
}
Model m = createMemModel();
RDFReader rdr = m.getReader();
rdr.setErrorHandler(this);
expected = new int[] { WARN_ENCODING_MISMATCH, ERR_ENCODING_MISMATCH };
rdr.read(m, r, "http://example.org/");
checkExpected();
}
use of org.apache.jena.rdf.model.RDFReader in project jena by apache.
the class MoreTests method testARPMacRoman.
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();
}
use of org.apache.jena.rdf.model.RDFReader in project jena by apache.
the class ExceptionTests method testDefaultDemotedFatal.
public void testDefaultDemotedFatal() {
RDFDefaultErrorHandler.silent = true;
try {
Model m = ModelFactory.createDefaultModel();
RDFReader 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;
}
}
Aggregations