Search in sources :

Example 6 with RDFReaderI

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

the class MoreTests method testEmptyBaseParamError.

public void testEmptyBaseParamError() 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_RESOLVING_URI_AGAINST_EMPTY_BASE };
        rdr.read(m, fin, "");
    }
    Model m1 = createMemModel();
    m1.createResource("#foo").addProperty(RDF.value, "abc");
    assertTrue("Empty base URI should produce relative URI.[" + m.toString() + "]", m.isIsomorphicWith(m1));
    checkExpected();
}
Also used : RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) Model(org.apache.jena.rdf.model.Model)

Example 7 with RDFReaderI

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

the class MoreTests method testEmptyBaseParamOK.

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

Example 8 with RDFReaderI

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

the class MoreTests method testRelativeBaseParamOK.

public void testRelativeBaseParamOK() 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_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 : RDFReaderI(org.apache.jena.rdf.model.RDFReaderI) Model(org.apache.jena.rdf.model.Model)

Example 9 with RDFReaderI

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

the class MoreTests method testIRIRules_3.

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

Example 10 with RDFReaderI

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

the class MoreTests method testNullBaseParamError.

public void testNullBaseParamError() 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[] { ERR_RESOLVING_URI_AGAINST_NULL_BASE, WARN_RELATIVE_URI };
        rdr.read(m, fin, null);
    }
    checkExpected();
}
Also used : 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