Search in sources :

Example 11 with RDFReader

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

the class MoreTests method testEmptyBaseParamOK.

public void testEmptyBaseParamOK() 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, "");
    }
    assertTrue("Empty base URI should have no effect.[" + m1.toString() + "]", m.isIsomorphicWith(m1));
    checkExpected();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 12 with RDFReader

use of org.apache.jena.rdf.model.RDFReader 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());
        RDFReader 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();
}
Also used : Model(org.apache.jena.rdf.model.Model) IRIFactory(org.apache.jena.iri.IRIFactory) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 13 with RDFReader

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

the class MoreTests method testBaseTruncation.

public void testBaseTruncation() 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[] { 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();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 14 with RDFReader

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

the class MoreTests method testRelativeBaseParamOK.

public void testRelativeBaseParamOK() 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[] { WARN_RELATIVE_URI };
        rdr.read(m, fin, "foo/");
    }
    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 on model.[" + m1.toString() + "]", m.isIsomorphicWith(m1));
    checkExpected();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 15 with RDFReader

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

the class TestReaderEvents method testReaderEvent.

public void testReaderEvent(final String language, final String emptyModel) {
    final RecordingModelListener L = new RecordingModelListener();
    model.register(L);
    final RDFReader r = model.getReader(language);
    final StringReader stringReader = new StringReader(emptyModel);
    r.read(model, stringReader, "");
    L.assertHasStart(new Object[] { "someEvent", model, GraphEvents.startRead });
    L.assertHasEnd(new Object[] { "someEvent", model, GraphEvents.finishRead });
}
Also used : StringReader(java.io.StringReader) RDFReader(org.apache.jena.rdf.model.RDFReader) RecordingModelListener(org.apache.jena.rdf.model.test.helpers.RecordingModelListener)

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