Search in sources :

Example 31 with RDFReader

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

the class MoreTests method testIRIRules_2a.

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

Example 32 with RDFReader

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

the class MoreTests method testBadBaseParamOK.

public void testBadBaseParamOK() 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 };
        rdr.read(m, fin, "http://jjc^3.org/demo.mp3");
    }
    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 33 with RDFReader

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

the class TestTurtle method runTest.

@Override
public void runTest() {
    Model model = ModelFactory.createDefaultModel();
    RDFReader t = new TurtleReader();
    try {
        if (baseIRI != null)
            t.read(model, FileManager.get().open(input), baseIRI);
        else
            t.read(model, input);
        // "http://www.w3.org/2001/sw/DataAccess/df1/tests/rdfq-results.ttl"
        String syntax = FileUtils.guessLang(output, FileUtils.langNTriple);
        Model results = FileManager.get().loadModel(output, syntax);
        boolean b = model.isIsomorphicWith(results);
        if (!b)
            assertTrue("Models not isomorphic", b);
    } catch (TurtleParseException ex) {
        throw ex;
    }
}
Also used : TurtleParseException(org.apache.jena.n3.turtle.TurtleParseException) Model(org.apache.jena.rdf.model.Model) TurtleReader(org.apache.jena.n3.turtle.TurtleReader) RDFReader(org.apache.jena.rdf.model.RDFReader)

Example 34 with RDFReader

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

the class TestReaders method testGetNTripleReader.

/**
     * Test to ensure that the reader is set.
     */
public void testGetNTripleReader() {
    final RDFReader reader = model.getReader("N-TRIPLE");
    Assert.assertNotNull(reader);
}
Also used : 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