François-Paul Servant created JENA-1276:
-------------------------------------------

             Summary: "loading remote context failed" reading JSON-LD
                 Key: JENA-1276
                 URL: https://issues.apache.org/jira/browse/JENA-1276
             Project: Apache Jena
          Issue Type: Bug
          Components: ARQ
    Affects Versions: Jena 3.1.1
         Environment: mac osx 10.11, eclipse mars
            Reporter: François-Paul Servant


getting org.apache.jena.riot.RiotException: loading remote context failed: 
http://schema.org/ reading json-ld with an @context set to schema.org

see https://github.com/apache/jena/pull/203

public class TestJsonLDReader {
    @Test public final void simpleReadTest() {
        try {
            String jsonld = someSchemaDorOrgJsonld();
            Model m = ModelFactory.createDefaultModel();
            try (StringReader reader = new StringReader(jsonld)) {
                m.read(reader, null, "JSON-LD");              
            }
            assertJohnDoeIsOK(m);
        } catch (RiotException e) {
            // org.apache.jena.riot.RiotException: loading remote context 
failed: http://schema.org/
            e.printStackTrace();
        }
    }

    /** Example data */
    private String someSchemaDorOrgJsonld() {
        return "{\"@id\":\"_:b0\",\"@type\":\"Person\",\"name\":\"John 
Doe\",\"@context\":\"http://schema.org/\"}";;
    }

    /** Checking that the data loaded from someSchemaDorOrgJsonld into a model, 
is OK */
    private void assertJohnDoeIsOK(Model m) {
        assertTrue(m.contains(null, RDF.type, 
m.createResource("http://schema.org/Person";)));
        assertTrue(m.contains(null, m.createProperty("http://schema.org/name";), 
"John Doe"));       
    }
}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to