Search in sources :

Example 6 with RDFReader

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

the class MoreTests method testIRIRules_3.

public void testIRIRules_3() {
    Model model = ModelFactory.createDefaultModel();
    RDFReader 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 : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 7 with RDFReader

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

the class MoreTests method testBadBaseParamError.

public void testBadBaseParamError() throws IOException {
    Model m = createMemModel();
    RDFReader 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_MALFORMED_URI, WARN_MALFORMED_URI, //        WARN_RELATIVE_URI, ERR_RESOLVING_AGAINST_MALFORMED_BASE};
        ERR_RESOLVING_AGAINST_MALFORMED_BASE };
        rdr.read(m, fin, "http://jjc^3.org/demo.mp3");
    }
    Model m1 = createMemModel();
    assertTrue("Bad base URI should produce no URIs in model.[" + m.toString() + "]", m.isIsomorphicWith(m1));
    checkExpected();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 8 with RDFReader

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

the class MoreTests method testNullBaseParamError.

public void testNullBaseParamError() throws IOException {
    Model m = createMemModel();
    RDFReader 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 : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 9 with RDFReader

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

the class MoreTests method testRelativeBaseParamError.

public void testRelativeBaseParamError() throws IOException {
    Model m = createMemModel();
    RDFReader 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();
}
Also used : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 10 with RDFReader

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

the class MoreTests method testEmptyBaseParamError.

public void testEmptyBaseParamError() throws IOException {
    Model m = createMemModel();
    RDFReader 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 : Model(org.apache.jena.rdf.model.Model) RDFReader(org.apache.jena.rdf.model.RDFReader)

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