use of org.apache.jena.rdf.model.RDFReaderI in project jena by apache.
the class MoreTests method testBaseTruncation.
public void testBaseTruncation() throws IOException {
Model m = createMemModel();
Model m1 = createMemModel();
RDFReaderI rdr = m.getReader();
try (FileInputStream fin = new FileInputStream("testing/wg/rdfms-identity-anon-resources/test001.rdf")) {
rdr.setErrorHandler(this);
expected = new int[] { WARN_MALFORMED_URI, WARN_RELATIVE_URI };
rdr.read(m, fin, "ht#tp://jjc3.org/demo.mp3#frag");
}
try (FileInputStream fin = new FileInputStream("testing/wg/rdfms-identity-anon-resources/test001.rdf")) {
rdr.read(m1, fin, "");
}
assertTrue("Bad base URI should have no effect.[" + m1.toString() + "]", m.isIsomorphicWith(m1));
checkExpected();
}
use of org.apache.jena.rdf.model.RDFReaderI in project jena by apache.
the class MoreTests method testRelativeBaseParamError.
public void testRelativeBaseParamError() 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_RELATIVE_URI, WARN_RELATIVE_URI, ERR_RESOLVING_AGAINST_RELATIVE_BASE };
rdr.setProperty("ERR_RESOLVING_AGAINST_RELATIVE_BASE", "EM_WARNING");
rdr.read(m, fin, "foo/");
}
Model m1 = createMemModel();
m1.createResource("foo/#foo").addProperty(RDF.value, "abc");
assertTrue("Relative base URI should produce relative URIs in model (when error suppressed).[" + m.toString() + "]", m.isIsomorphicWith(m1));
checkExpected();
}
use of org.apache.jena.rdf.model.RDFReaderI in project jena by apache.
the class MoreTests method testIRIRules_2.
public void testIRIRules_2() {
Model model = ModelFactory.createDefaultModel();
IRIFactory f = ARPOptions.getIRIFactoryGlobal();
try {
ARPOptions.setIRIFactoryGlobal(IRIFactory.iriImplementation());
RDFReaderI r = model.getReader("RDF/XML");
expected = new int[] { WARN_MALFORMED_URI, WARN_MALFORMED_URI };
r.setErrorHandler(this);
r.read(model, new StringReader(RDF_TEXT), "http://example/");
} finally {
ARPOptions.setIRIFactoryGlobal(f);
}
checkExpected();
}
use of org.apache.jena.rdf.model.RDFReaderI in project jena by apache.
the class TestXMLFeatures method checkPropURI.
public void checkPropURI(String s, String p, Object val, int behaviour) throws IOException {
// create triple and graph.
// BaseXMLWriter.dbg = true;
// SystemOutAndErr.block();
// TestLogger tl = new TestLogger(BaseXMLWriter.class);
blockLogger();
Node blank = NodeFactory.createBlankNode();
Node prop = NodeFactory.createURI(s);
Graph g = Factory.createGraphMem();
g.add(Triple.create(blank, prop, blank));
// create Model
Model m = ModelFactory.createModelForGraph(g);
// serialize
RDFWriterI rw = m.getWriter(lang);
if (p != null)
rw.setProperty(p, val);
try (StringWriter w = new StringWriter()) {
rw.write(m, w, "http://example.org/");
String f = w.toString();
switch(behaviour) {
case BadPropURI:
fail("Bad property URI <" + s + "> was not detected.");
return;
case BadURI:
fail("Bad URI <" + s + "> was not detected.");
return;
}
// read back in
Model m2 = createMemModel();
RDFReaderI rdr = m2.getReader("RDF/XML");
rdr.setProperty("error-mode", "lax");
try (StringReader sr = new StringReader(f)) {
rdr.read(m2, sr, "http://example.org/");
}
// check
switch(behaviour) {
case ExtraTriples:
assertTrue("Expecting Brickley behaviour.", m2.size() == 3);
break;
case NoError:
assertTrue("Comparing Model written out and read in.", m.isIsomorphicWith(m2));
break;
}
} catch (BadURIException e) {
if (behaviour == BadURI)
return;
throw e;
} catch (InvalidPropertyURIException je) {
if (behaviour == BadPropURI)
return;
throw je;
} catch (JenaException e) {
throw e;
} finally {
// BaseXMLWriter.dbg = false;
// tl.end();
unblockLogger();
// SystemOutAndErr.unblock();
}
}
use of org.apache.jena.rdf.model.RDFReaderI in project jena by apache.
the class MoreTests method testIcu2.
public void testIcu2() 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/icubugtwo.rdf")) {
rdr.setErrorHandler(this);
expected = new int[] { WARN_STRING_NOT_NORMAL_FORM_C };
rdr.read(m, r, "http://example.org/");
}
checkExpected();
}
Aggregations