use of org.apache.jena.rdfxml.xmlinput.SAX2RDFTest.RDFEHArray in project jena by apache.
the class SAX2RDFMoreTests method testLang.
public void testLang() throws Exception {
Model m = ModelFactory.createDefaultModel();
Model m2 = ModelFactory.createDefaultModel();
RDFEHArray eh = new RDFEHArray();
try (InputStream in = new FileInputStream("testing/wg/rdfms-xmllang/test004.rdf")) {
RDFReader w = m.getReader();
w.setErrorHandler(eh);
w.read(m, in, "http://example.org/");
}
RDFEHArray eh2 = new RDFEHArray();
try (InputStream in = new FileInputStream("testing/wg/rdfms-xmllang/test003.rdf")) {
XMLReader saxParser = new SAXParser();
SAX2Model handler = SAX2Model.create("http://example.org/", m2, "fr");
SAX2RDF.installHandlers(saxParser, handler);
handler.setErrorHandler(eh2);
InputSource ins = new InputSource(in);
ins.setSystemId("http://example.org/");
try {
try {
saxParser.parse(ins);
} finally {
handler.close();
}
} catch (SAXParseException e) {
// already reported, leave it be.
}
}
/*
* 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 <a.length;i++)
* System.err.println(eh.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]);
}
}
Aggregations